如何组织我的课程?

发布于 2024-07-24 14:46:45 字数 293 浏览 3 评论 0原文

我正在 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 技术交流群。

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

发布评论

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

评论(2

白首有我共你 2024-07-31 14:46:46

我坚决拥护简单/按需重构的方法。

在这种方法中,您只需将所有类放入一个名称空间中,然后就可以让代码正常工作。 无论在开发周期的哪个阶段,您开始对所拥有的类感到“混乱”,并在逻辑上将它们分成一个或两个与您对每个组的看法相匹配的命名空间。

随着您的继续,定期/根据需要重复此过程,当您的文件总数增加时,您可以考虑构建文件夹以反映您的名称空间。

这可能并不适合每个人,但如果“完成然后微调”的想法对您有吸引力,那么我会推荐这种方法。

更新:

链接到 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.

我爱人 2024-07-31 14:46:46

考虑将类别设为枚举(照片可以有一组类别)。 考虑专辑类别。 允许一张照片出现在多个相册中。 使用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.

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