views:

281

answers:

5

I am trying to come up with a best practices on project directory structure.

my latest thought is that there should be no classes in the root directory of a project. All classes must go under one of the following directories

  • UI
  • BusinessObjects
  • BusinessLogic
  • DataAccess

i would like to hear other people thought on if there are use cases for putting things at the root level or find classes that wouldn't fit into

+1  A: 

This blog should provide you with some interesting reading, despite being three years old. It might give you ideas besides those of just directory structure.

dove
A: 

The only files I put into root folder are Program.cs and Program.ico (if it's executable application).

lubos hasko
+7  A: 

If you're talking about C# then I would separate your DAL, BLL, GUI to different projects instead of one project. And have one solution. This will force each code file to be inside of one of the projects.

I've added an example:

  • Solution: ProjectName
    • Project: DAL (Namespace: ProjectName.DAL)
      • Folder: Repositories (Namespace: ProjectName.DAL.Repositories)
      • Folder: Contracts (Namespace: ProjectName.DAL.Contracts)
      • Files: Your Entity Mapping configuration
    • Project: BLL (Namespace: ProjectName.BLL)
      • Folder: Services (Namespace: Project.BLL.Services)
      • Folder: Entities (Namespace: Project.BLL.Entities)
      • Files: IoC configuration classes/general Business Logic
    • Project: Shared (Namespace: ProjectName.Shared)
      • Files: General shared logic throught your whole application (for instance an InvalidIdentifier constant)
      • This project should not reference other projects in the solution..
    • Project: Website (Namespace: ProjectName.Website)
      • Your asp.net website UI
    • Project: Winforms (Namespace: ProjectName.Winforms)
      • Your winforms UI

If possible you should give the website and winforms project a name relative to your application.

Davy Landman
A: 

I don't do it, but it has nothing to do with the directory structure (for me). I want all my code in meaningful namespaces.

Kyle West
A: 

I always put the base class for my projects exceptions in the root.

Sean