简体   繁体   English

是否基于文档的应用程序?

[英]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-side. 我计划的UI包含一个垂直拆分视图,左侧有一个类似iTunes的OutlineView。 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. 当您在该大纲视图中单击“学生”项时,右侧面板的内容将从ManageStudents NIB交换。 Likewise, if you click on the "Invoices" item in the outline view, the current view will be replaced with the ViewInvoices view. 同样,如果在大纲视图中单击“发票”项,则当前视图将替换为ViewInvoices视图。 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). 另一方面,我看到的基于NSDocument的示例给我带来了很多好处(老实说,我在网络上看到的大多数示例似乎都是基于文档的)。 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) 另外,指向某处的指针可以在何时/不适合使用NSDocument时提供具体建议(Apple的“基于文档的应用程序概述”有帮助地建议“文字处理器和电子表格应用程序是基于文档的应用程序的两个示例”)-我希望对于某些更具有洞察力且与其他实际应用相关的东西)

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. 如果您发现使用基于NSDocument的好处,那就去吧。 The reason I say this is because if there is a lot of text writing/reading, then it should be a good choice. 我之所以这样说是因为,如果有大量的文字写作/阅读,那么它应该是一个不错的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM