Graham Cox wrote:
On 30/11/2009, at 12:04 PM, Jason Stephenson wrote:

NSDocument and the document-based architecture in Cocoa is a bad
example of MVC.


As a statement that doesn't really stand up to scrutiny. Sure, you
can abuse NSDocument and violate MVC, but as it comes it does not. A
document might own (or be) the data model, and it might also keep a
list of window controllers. How does that violate MVC? NSDocument is
just 'M', and nothing more.

-makeWindowControllers and I disagree with you.


Let me rephrase what I said earlier:

NSDocument and the document-based architecture in Cocoa is a bad example of MVC in as much as people confuse NSDocument with a document model class when it is a model controller.--This is the confusion that I think our friend Sandro is running into.

NSDocument doesn't merely represent the document's data as in a "pure" MVC design, rather it is a controller for the document's data. The subsection of the Document-Based Applications Overview entitled "The Role of NSDocument" makes this abundantly clear. The actual model data for the document is very often an ivar of the NSDocument subclass.

A data model should not be required to create controllers for GUI elements as NSDocument is asked to do by NSDocumentController when a new document is created. The creation and management of GUI elements is typically a controller's job, not a model's job. A model should be abstract in the sense that it is not tied to any particular visual representation of the data. It should work in a command line application as well as it works in a GUI application.--Admittedly, this is an ideal.

While NSDocument doesn't necessarily break MVC, I think the class is poorly named. It should probably more properly be named NSDocumentController and NSDocumentController would more properly be named NSDocumentControllerController, but that's a bit awkward.

Now, I will stop before the moderators hit me with the moderation flag, because I have a feeling we're going over old ground.



--Graham



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to