基于文档的应用程序,还是不?

发布于 2024-09-30 23:59:12 字数 585 浏览 5 评论 0原文

我正在编写一个可用于管理舞蹈学院的桌面应用程序。我的核心数据模型包含学生、教师、班级、发票等实体以及它们之间的各种关系。

我计划的 UI 由一个垂直分割视图组成,左侧有一个类似 iTunes 的 OutlineView。当您单击大纲视图中的“学生”项目时,右侧面板的内容将从 ManageStudents NIB 中交换。同样,如果单击大纲视图中的“发票”项,当前视图将替换为 ViewInvoices 视图。相当简单,是吗?

我最大的困境是是否要基于文档?我所有的阅读都表明,如果用户一次打开多个实体实例,这将是一个不错的选择。此处的情况并非如此 - 在任何时间点都只会打开一个主窗口实例。

另一方面,我可以从我看到的基于 NSDocument 的示例中看到很多好处(说实话,我在网络上看到的大多数示例似乎都是基于文档的)。如果我沿着这条路走下去,我很好奇是否会为每个基本实体定义一种文档类型,或者仅为一个控制文档。

任何指导将不胜感激。或者,指向某个地方,就 NSDocument 何时合适/不合适提供具体建议(Apple 的“基于文档的应用程序概述”很有帮助地建议“文字处理器和电子表格应用程序是基于文档的应用程序的两个示例” - 我希望以获得更具洞察力和与其他实际应用程序相关的东西)

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

棒棒糖 2024-10-07 23:59:12

考虑一下您的问题领域。 “文档”模型是什么?舞蹈学院?如果是这样,并且您认为您的用户只会管理一所学院,那么基于文档的模型是不必要的。另一方面,如果您认为一个文档代表一位教师,那么一位学院经理可能会想要与多名教师打交道,因此文档模型似乎是合适的。

关键问题之一是独立性。如果应用程序模型中的所有对象都是相关的,则无需管理独立文档。另一方面,如果存在一个松散的对象集合,每个对象都有自己的一组相关“子对象”,那么这看起来像是一个文档集合。这就是为什么文字处理程序是基于文档的:一个文件中的文本、属性和图像与另一个文件中的文本、属性和图像无关,因此将它们视为独立文档是有意义的。

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.

梦里的微风 2024-10-07 23:59:12

如果您发现基于 NSDocument 的好处,那就去吧。我之所以这么说是因为如果有大量的文字写作/阅读,那么它应该是一个不错的选择。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文