0

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.

MCardinale
  • 1,408
  • 2
  • 15
  • 22
  • 1
    Three points. (1) The outermost namespace should be the name of your company; it should be something that will never conflict with anyone else's namespace. (2) Never name a class and a namespace the same thing; doing so both makes it very confusing and defeats the purpose of namespaces. (If you put a class into a namespace because it collided with another class of the same name, making the namespace that name too makes the situation worse!) And (3) go get yourself a copy of Framework Design Guidelines right now; it is all about answering questions like this. – Eric Lippert Jun 19 '09 at 05:48

2 Answers2

2

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.

John Weldon
  • 39,849
  • 11
  • 94
  • 127
  • That being said; the ASP/MVC folks have some 'conventions' they use that would be very helpful for you if you followed... – John Weldon Jun 19 '09 at 04:05
0

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.

Ray Tayek
  • 9,841
  • 8
  • 50
  • 90