There's a lot of confusion over MVC but after flicking through a Head First patterns book (As a side note I hate that brand, though this example was quite good) it claims that MVC or Model View Controller is a hybrid of multiple patterns - mediator, observer etc...
In a recent prototype I did the following, it's C# but should be straightforward.
Person : IPerson {
public Name { get; set;}
public Age { get; set;}
}
IPerson is just an interface defining the above - I've left it out for simplicity.
PersonController : IPersonController {
public event DetailsUpdated;
public void SetAge(int age);
public int GetAge();
public void SetName(string name);
public string GetName();
}
I know the above could be properties themselves - but this is just a simple example. The event is fired every time some data changes - e.g. in SetAge/SetName.
interface IView {
void Initialize();
void SetAgeClicked(object sender, EventArgs e);
void SetNameClicked(object sender, EventArgs e);
}
Initialize wires stuff up - e.g. text boxes on the form. SetAge/SetName are the button events - so the form/page etc.. using must have these methods.
Form : IView {
// IView is implemented.
// Form is wired up
// Initialize is set etc...
}
I hear the test of MVC is when you add a new view is it easy to get stuff up and running - well yes it was. However, is this MVC? Is this something else?
Any advice/input would be great. It works - it just want to know why though.
Thanks.