Document-based application, or not?

戏子无情 提交于 2019-12-21 05:14:13

问题


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-side. 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)


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/4133048/document-based-application-or-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!