开发者

Document-based application, or not?

I'm writing a desktop app that could be used to manage a dance academy. My Core Data model contains such entities as Student, Teacher, Class, Invoice, etc along with the various relationships between them.

My planned UI consists of a vertical split view with an iTunes-like OutlineView on the left hand-si开发者_开发知识库de. When you click on the "Students" item in that outline view, the contents of the right-hand panel get swapped in from the ManageStudents NIB. Likewise, if you click on the "Invoices" item in the outline view, the current view will be replaced with the ViewInvoices view. Fairly simple, yes?

My big dilemma is whether to go document-based, or not? All my reading suggests that that would be a good choice if the user has multiple instances of entities open at a time. That isn't the case here - there would only ever be one instance of the main window open at any point in time.

On the other hand, I can see so much benefit from the NSDocument-based examples I see (and to be honest, most examples I can see on the web appear to be document-based). If I were to go down this path, I am curious as to whether I would define a document type for each of my basic entities, or just one controlling document.

Any guidance would be gratefully received. Alternatively, pointers to somewhere that gives concrete advice on when NSDocument is/isn't appropriate (the "Document-Based Applications Overview" from Apple helpfully advises "Word processors and spreadsheet applications are two examples of document-based applications" - I was hoping for something a bit more insightful and relevant for other real-world applications)


Think about your problem domain. What would a "document" model? A dance academy? If so, and you think that your users will only be managing one academy, then the document-based model is unnecessary. On the other hand if you think that a document represents a teacher, then it's likely one academy manager will want to deal with multiple teachers so the document model seems appropriate.

The key question is one of independence. If all of the objects in your application's model are related then there's no need to manage independent documents. If, on the other hand, there is a loose collection of objects which each have their own set of related "children", then this seems like a collection of documents. This is why a word processor is document-based: the text, attributes and images in one file is unrelated to those in another file, so it makes sense to treat them as independent documents.


If you see benefit to go to NSDocument-based, go for it. The reason I say this is because if there is a lot of text writing/reading, then it should be a good choice.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜