您如何组织大型项目的课程?
我们的应用程序中有大量功能,可以非常具体地描述为模块。 通常有某种设置对话框,然后当用户单击“确定”时,它会配置一个进程来运行并运行该进程。 有时,他们的参与程度更高,用户会打开新对话框并在该对话框上工作一段时间,执行许多对底层数据库进行更改的操作。
我通常会得到几个标准类
ConfigPanel.cs
ConfigPanelData.cs
ProcessRunner.cs
ApiWrapper.cs (for calling the process from somewhere else)
如果我有一个更多的端到端模块,它可能是 WorkerPanel.cs WorkerData.cs SetupOptions.cs(运行之间保持面板状态) 库/无论后端StuffINeedToSupportModule 现在,每个ApiWrapper
都有一个文件夹:
UI/Panels/
Module1Panel.cs
Module2Panel.cs
UI/PanelData/
Module1PanelData.cs
Module2PanelData.cs
UI/PanelManagers
Module1PanelManager.cs
Module2PanelManager.cs
Core/Module1/
Module1.cs
Module1Helpers.cs
Core/Module2/
Module2.cs
Module2Helpers.cs
如您所见,所有内容都真正分散开来。 由于有 50 多个模块,这些文件夹并没有真正组织起来。 即使按照子系统将它们分解,它们仍然是一团糟。 将所有内容放在一起以便所有内容都按功能而不是类类型分隔,这会是糟糕的设计吗?
Module1/
Module1Panel.cs
Module1PanelData.cs
Module1PanelManager.cs
Module1PanelLib.cs
Module1PanelWrapper.cs
Module2/
Module2Panel.cs
Module2PanelData.cs
Module2PanelManager.cs
Module2PanelLib.cs
Module2PanelWrapper.cs
您如何组织课程?有哪些优点/缺点?
We have a ton of features in our application that can be described very concretely as a module. The usually have some sort of setup dialog, then when the user clicks ok, it configures a process to run and runs that process. Sometimes they are more involed and the user will open up the new dialog and work on the dialog for a while, doing many things that make changes to the underlying database.
I typically end up with several standard classes
ConfigPanel.cs
ConfigPanelData.cs
ProcessRunner.cs
ApiWrapper.cs (for calling the process from somewhere else)
If I had a more end to end module it might be
WorkerPanel.cs
WorkerData.cs
SetupOptions.cs (panel state persisted between runs)
Lib/WhateverBackendStuffINeedToSupportModule
ApiWrapper
Right now there are folders for each one:
UI/Panels/
Module1Panel.cs
Module2Panel.cs
UI/PanelData/
Module1PanelData.cs
Module2PanelData.cs
UI/PanelManagers
Module1PanelManager.cs
Module2PanelManager.cs
Core/Module1/
Module1.cs
Module1Helpers.cs
Core/Module2/
Module2.cs
Module2Helpers.cs
As you can see, everything is really spread out. With 50+ modules those folders aren't really organized. Even breaking them up by subsystem, they are still a mess. Would it be bad design to just put everything together so everything is separated by function rather than class type?
Module1/
Module1Panel.cs
Module1PanelData.cs
Module1PanelManager.cs
Module1PanelLib.cs
Module1PanelWrapper.cs
Module2/
Module2Panel.cs
Module2PanelData.cs
Module2PanelManager.cs
Module2PanelLib.cs
Module2PanelWrapper.cs
How do you organize your classes and what are the advantages / disadvantages?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有通用规则,这取决于具体情况、您的个人喜好以及代码中的更改模式。
不过,我建议执行以下操作:
There's no general rule, it depends on the situation, your personal preferences and change patterns in your code.
However I would suggest doing the following: