Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it OK to have code in the root of a project?

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

like image 925
leora Avatar asked Nov 22 '08 12:11

leora


2 Answers

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.

like image 53
Davy Landman Avatar answered Oct 15 '22 17:10

Davy Landman


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.

like image 36
dove Avatar answered Oct 15 '22 15:10

dove