如何组织我的课程?
我正在 ASP.NET MVC 中开发一个小项目来管理照片,但我不知道如何在命名空间中组织我的类。
我有 2 个基类(照片和类别)。 我应该将这些类放入哪个命名空间中? 领域? POCO/POJO?
对于数据访问,我在 DAO 命名空间中有另外 2 个类:PhotoDAO 和 CategoryDAO。 (对吗?)
我应该把我的业务逻辑类放在哪个命名空间以及如何命名它们?
有人对我必须使用/学习哪些设计模式有任何建议吗?
很抱歉问这么基本的问题。 谢谢。
I'm developing a small project in ASP.NET MVC to manage photos, but I don't know how to organize my classes in namespaces.
I have 2 base classes (Photo and Category). Should I put these classes into which namespace? Domain? POCO/POJO?
For Data Access, I have more 2 classes, PhotoDAO and CategoryDAO in DAO namespace. (Is it right?)
Which namespace should I put my business logic classes and how name them?
Does someone has any advice which design patterns I have to use/study?
I'm sorry asking so basic questions. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我坚决拥护简单/按需重构的方法。
在这种方法中,您只需将所有类放入一个名称空间中,然后就可以让代码正常工作。 无论在开发周期的哪个阶段,您开始对所拥有的类感到“混乱”,并在逻辑上将它们分成一个或两个与您对每个组的看法相匹配的命名空间。
随着您的继续,定期/根据需要重复此过程,当您的文件总数增加时,您可以考虑构建文件夹以反映您的名称空间。
这可能并不适合每个人,但如果“完成然后微调”的想法对您有吸引力,那么我会推荐这种方法。
更新:
链接到 MVC 教程,这将使您了解他们如何推荐内容做完了。
I firmly espouse the simplicity / refactor-as-needed approach.
In this approach you just put all your classes into one namespace, and get your code working. At whichever point in the development cycle you begin to feel 'cluttered' think about the classes you have and separate them logically into one or two namespaces that match how you think of each group.
As you go on, repeat this process regularly/as-needed and when your total file count grows you can consider structuring your folders to reflect your namespaces.
This may not be the way for everyone, but if the idea of get-it-done and then fine-tune appeals to you, then I would recommend this approach.
Updated:
Link to MVC tutorials which will give you an idea of how they recommend things be done.
考虑将类别设为枚举(照片可以有一组类别)。 考虑专辑类别。 允许一张照片出现在多个相册中。 使用mvc微型架构。 看看 picasa。
consider making category an enum (photo can have a set of categories). consider an album class. allow a photo to be in many albums. use the mvc mini-architecture. take a look at picasa.