Welcome Guest, Not a member yet? Register   Sign In
Proper MVC design
#2

[eluser]gtech[/eluser]
I am still building on my understanding of MVC so don't take this as gospel, but I will have a go..

[quote author="AtlantixMedia" date="1197240331"]Hello everybody,

now my questions are:

1) should I have different controllers for each important section of the admin area instead of having just one Admin controller? for example, one controller for sitemaps, and so on?
[/quote]

I don't think it really matters. Personally I have a controller for each important section, but for me it makes sense to as my methods are quite long. If your methods are only a few lines long then maybe it makes sense to put them in the admin controller. maybe use a bit of common sense and try and keep the code maintainable and readable.

[quote author="AtlantixMedia" date="1197240331"]
2) I have read that the View is independent on changes occuring to the Model. That is, if a column name changes in the database, the View will still work. I do not understand this as the Model gets database data and passes it to the Controller as an associative array. The View then blends that with HTML but it may refer to array indexes which are actually database table fields names. i.e.: <?php echo $data['Item_ID']; ?> where Item_ID is a table field name. am I missing something here?
[/quote]

My interpretation is that when somebody is referring to the view being independent on changes occurring to the model, they mean that the view should not be making alterations to any data (e.g. inserts updates). Its OK for a view to ask a model for information and if a field name is changed in the database then you would expect to have to change a variable name here and there.

maybe you could source where you got your information from so I can double check my understanding.

Its the controllers Job to request changes to the model by calling an insert or update method for example. A controller can also request information and pass it to the view (The view can also request information by calling the model directly BUT it cannot request changes).

[url="http://en.wikipedia.org/wiki/Model-view-controller"][wikipedias take][/url]

you can search the forums for this as its been discussed quite a lot.


Messages In This Thread
Proper MVC design - by El Forum - 12-09-2007, 10:45 AM
Proper MVC design - by El Forum - 12-09-2007, 12:26 PM
Proper MVC design - by El Forum - 12-09-2007, 12:47 PM
Proper MVC design - by El Forum - 12-09-2007, 12:53 PM
Proper MVC design - by El Forum - 12-09-2007, 01:02 PM
Proper MVC design - by El Forum - 12-10-2007, 07:25 AM



Theme © iAndrew 2016 - Forum software by © MyBB