dimanche 1 février 2015

Controller in MVC


Alright so it is an essential part of OOP that one class should only do one thing, and it makes sense. In practice I've seen that classes which don't obey this rule get thick and cluttered.


So I was thinking and I kinda can't wrap my head around how the controller fits into this. If each method of a controller should represent a different page from the website, then this doesn't really make much sense to me. Yes the pages may be related, such as /user/edit and /user/view which are in the same controller, but if I'm going to display one of those pages, loading the other method and possibly many more is completely pointless.


It's probably that I'm missing something since people have been using this approach in major frameworks, but can you help me figure out what?





Aucun commentaire:

Enregistrer un commentaire