Which do you guys prefer? I've been looking into both and there definitely seems to be some inconsistency in what people call them.
I will try and jot down what the differences are and you can correct me if I'm wrong.
MVC
- Model holds references to it's own observers (Views), on updates to the model it notifies observers.
- Views pass all events and messages to the Controller. Views update their content when they are notified by the model that a change has occured. View holds a reference to the Controller and to the Model.
- Controller holds the Model and (sometimes) the Views. The Views will call the Controllers methods corresponding with user input, the Controller then maniuplates the Model as accordingly, and sometimes manipulates the View (blocking out buttons on certain View clicks, etc. )
MVP
- Model has no references to the View. Only provides the data abstraction for the program. Model holds no reference to anything.
- As in MVC Views call the corresponding Controller methods depending on user input. View has a reference only to the Controller.
- Controller has a reference to the Views and the Model. When a View calls a method in the Controller, the Controller manipulates the Model then manipulates the View.
I'm pretty sure I understand how MVC works, just my understanding if MVP is kind of iffy. I really really like MVC, but the only part that doesn't sit that well with me is the fact that the Model, which is supposed to only be an abstraction of the data layer, also holds references to Views and does updating. That doesn't make sense.