Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Do you have any particular style of organizing projects?

For example, currently I'm creating a project for a couple of schools here in Bolivia, this is how I organized it:

TutoMentor (Solution)
TutoMentor.UI   (Winforms project)
TutoMentor.Data (Class library project)

How exactly do you organize your project? Do you have an example of something you organized and are proud of? Can you share a screenshot of the Solution pane?

In the UI area of my application, I'm having trouble deciding on a good schema to organize different forms and where they belong.


Edit:

What about organizing different forms in the .UI project? Where/how should I group different form? Putting them all in root level of the project is a bad idea.

share|improve this question

closed as not constructive by Jim G., Walter, Dynamic, ChrisF Oct 10 '12 at 10:04

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Wow, a 450 bounty!? –  muntoo Feb 1 '11 at 0:50
1  
@muntoo: Yeah, I'm really interested in some great answers. :) –  Sergio Feb 1 '11 at 3:47
    
It should be stated explicitly that you ask about C#. I personally never see the tags. –  Pithikos Sep 26 at 9:22

8 Answers 8

up vote 50 down vote accepted

When designing a project and laying out the architecture I start from two directions. First I look at the project being designed and determine what the buisness problems is that needs to be solved. I look at the people who will be using it and start with a crude UI design. At this point I am ignoring the data and just looking at what the users are asking for and who will be using it.

Once I have a basic understanding of what they are asking for I determine what the core data is that they will be manipulating and begin a basic database layout for that data. Then I start to ask questions to define the business rules that surround the data.

By starting from both ends independantly I am able to lay out a project in a way that melds the two ends together. I always try to keep the designs seperate for as long as possible before melding them together, but keep in mind the requirements of each as I move forward.

Once I have a good solid understanding of each end of the problem I begin to lay out the structure of the project that will be created to solve the problem.

Once the basic layout of the project solution is created I look at the functionality of the project and set up a base set of namespaces that are used depending on the type of work being done. This may be things like Account, Shopping Cart, Surveys, etc.

Here is the basic solution layout that I always start with. As the projects get better defined I refine it to meet the specific needs of the project. Some areas may be merged with others and I may add a few special ones as needed.

SolutionName

.ProjectNameDocuments
    For large projects there are certain documents that need to be kept with
    it. For this I actually create a seperate project or folder within the 
    solution to hold them.
.ProjectNameUnitTest
    Unit testing always depends on the project some times it is just really 
    basic to catch edge cases and some times it is set up for full code 
    coverage.  Recently have added graphical unit testing to the arsenal.
.ProjectNameInstaller
    Some projects have specific installation requirements that need to be 
    handled at a project level.
.ProjectNameClassLibrary
    If there is a need for web services, APIs, DLLs or such.
.ProjectNameScripts (**Added 2/29/2012**)
    I am adding this because I just found a need for one in my current project.  
    This project holds the following types of scripts: SQL (Tables, procs, views), 
    SQL Data update scripts, VBScripts, etc.
.ProjectName
    .DataRepository 
        Contains base data classes and database communication.  Sometimes 
        also hold a directory that contains any SQL procs or other specific 
        code.  
    .DataClasses
        Contains the base classes, structs, and enums that are used in the 
        project.  These may be related to but not necessarily be connected to 
        the ones in the data repository.
    .Services 
        Performs all CRUD actions with the Data, done in a way that the 
        repository can be changed out with no need to rewrite any higher 
        level code.
    .Business
        Performs any data calculations, business level data validation, does 
        most interaction with the Service layer.
    .Helpers
        I always create a code module that contains helper classes.  These 
        may be extensions on system items, standard validation tools, 
        regular expressions or custom built items.  
    .UserInterface
        The user interface is built to display and manipulate the data.  
        UI Forms always get organized by functional unit namespace with an 
        additional folder for shard forms and one for custom controls.
share|improve this answer
    
Best answer so far! –  Sergio Feb 4 '11 at 16:01
    
Enjoy the bounty, your answer helped me out tremendously. –  Sergio Feb 5 '11 at 23:01
    
Bounty well deserved! Good job on the comments under each node. A good idea to save this as a VS template project :) –  invert Feb 7 '11 at 6:27
    
I store my folder structure of all my projects like so: a:\Source\VS2010\Web\Apps or a:\source\vs2010\WPF\Apps a:\source\vs2010\Silverlight\Apps as well. –  Rick Ratayczak Feb 9 '11 at 15:46
1  
@Amy I liked your answer very much, very detailed explanation. But I've seen in some examples people dividing DataRepository, DataClasses, Services, Business, etc into different projects instead of different folders in the same project. What would you say regarding this? What are the advantages/disadvantages between the two options? Thanks! –  emzero Apr 4 '12 at 19:20

Organizing Projects

I typically try to divide up my projects by namespace, like you say. Each tier of an application, or component is its own project. When it comes to how I decide how to break my solution up into projects, I focus on reusability and dependencies of those projects. I think about how other members of my team will be using the project, and if other projects we create down the road may benefit from using some component of the system.

For example, sometimes, just having this project, which has an entire set of frameworks (email, logging, etc) is sufficient:

MyCompany.Frameworks

Other times, I may want to break out frameworks into pieces, so that they can be imported individually:

MyCompany.Frameworks.Networking
MyCompany.Frameworks.Logging
MyCompany.Frameworks.SomeLOBFramework

Organizing Forms

Organizing Forms under a UI project will really morph as your project expands.

  • Small - A simple Forms folder could suffice for a very small project. Sometimes you can overengineer structures just like you can namespaces and make things way more complicated than they need to be.

  • Medium to Large - Here, I usually start dividing my forms into functional areas. If I have one part of my app that has 3 forms to manage a user and some that keep keep track of soccer games and scores, then I'll have a Forms > User area and a Forms > Games area or something like that. It really depends on the rest of the project, how many forms I have as to how fine-grained I break it up.

Remember, at the end of the day namespaces and folders are just there to help you organize and find things faster.


Really, it depends on your team, your projects, and what's easier for you. I would suggest that in general, you make separate projects for each layer/component of your system, but there are always exceptions.

For guidance on system architecture see Microsoft's Patterns and Practices site.

share|improve this answer

When I'm designing my application, I always see it as modules with some dependencies between them. When I have a design in mind, then I use a bottom-up strategy to develop it. I develop each module and then I get them working together.

Well, those modules are projects under my solution (usually class libraries). Each module has a different namespace and its own design (containing classes, etc).

One of those modules is the GUI (Graphical User Interface).

I also always use a Revision Control tool to track the changes in each project. I suggest Git. It's opensource, distributed and free to use.

share|improve this answer

I like dividing my projects into layers

That way it's easier to manage cyclic dependencies. I can guarantee that no project is importing the View project (layer) by mistake, for example. I also tend to break my layers in sub-layers. So all my solutions have a list of projects like this:

  • Product.Core
  • Product.Model
  • Product.Presenter
  • Product.Persistence
  • Product.UI
  • Product.Validation
  • Product.Report
  • Product.Web

They are the bigger "building blocks" of my application. Then inside each project I organize in namespaces more logically but it varies a lot. For UI when creating a lot of forms I try to think in a spacial division and then create namespaces for each "space". Let's say there's a bunch of user preferences user controls and forms, I'd have a namespace called UserPreferences for them, and so on.

share|improve this answer
    
What about: Product - Core - Model - Presenter - Persistence - UI - Validation - Report - Web –  Daniel Fisher lennybacon Jul 10 at 8:34

When I write code in .NET, there is a clear tendency to have clusters of related functionality. Each of which may have some sub-sets of the same. I like to break out the main groups physically - one of these per VS project. I then further subdivide logically using assemblies. Following this pattern, one of my current projects looks like this:

  • Wadmt (solution)
    • Wadmt.Common
    • Wadmt.Data
      • Wadmt.Data.MySql
      • Wadmt.Data.SqlServer
      • Wadmt.Data.Oracle
    • Wadmt.Domain
    • Wadmt.Services
    • Wadmt.Tests
      • Wadmt.Tests.Common
      • Wadmt.Tests.Domain
      • Wadmt.Tests.Services
      • Wadmt.Tests.Integration
    • Wadmt.Web

Hopefully that is useful to you. The levels of separation took me some time to figure out.

share|improve this answer
    
I would reduce "Wadmt". Keep the file System dry. That helps a lot when working on the console... –  Daniel Fisher lennybacon Jul 10 at 8:34

It's good to have a plan for organizing your solutions, and there are several ways of doing it. We have some functionality that is shared across multiple projects, which also provides consistency for our users. The project organization does depend on what we are doing. At it's core we will have:

Company (solution)
  Company.Common (shared library)
  Company.Project (Main application UI)
  Company.Project.UnitTests (Unit tests for all project modules)
  Company.Project.IntegrationTests (integration tests for all project modules)
  Company.Project.AutomationTests (tests that invoke the UI)

From there it really depends on the setup. If we have both a client application and a web front end (useful for collecting usage results in classroom or other research), we need a project that has the commonly shared code (i.e. the data objects that will be serialized).

  Company.Project.Model (ORM and business logic layer)
  Company.Project.Webapp (Web frontend/web service layer)
  Company.Project.WebClient (client code for web services)

Other subprojects may be added as necessary. As I said, it really depends on the project. Some projects are really simple, and only need core elements. We do try to fight arbitrary project separation, so dividing by layers really makes sense. The layers are defined by what needs to be shared across projects, solutions, or what needs to be plugins/extensions.

share|improve this answer

It’s Interesting that so many people don't consider DRY here. It happened a few times in my life that developers created directory structures that weren't able to build because of that. Keep the project name out off solution and project directories!

So here is my way:

{drive}:\{customer}\{apps|libs|tools}\{project}
  - cer
  - res
  - src
   - Common
   - Data
   - UI
   - Logic
   - Logic._Tests  
share|improve this answer
    
What's DRY? Abbreviation for something? –  Pithikos Aug 21 at 15:47
    
@Pithikos It's an acronym for Don't Repeat Yourself –  pero Sep 25 at 18:51

Each time I start on a new project I get a broad specification of what it is supposed to do. Having this input helps me by providing me of a context, therefore I go ahead and think the best (or most appropiate) method to achieve the projects goals. At this point I start thinking in which desgin patterns may hepl me provide the intended solution. Here is where I start organizing the project, taking into account the design patterns I will adopt for the project.

A couple of examples:

  1. If the project only reffers to building input data screens. Most probably I would use a MVC pattern.
  2. If the project is going to be used as a heavy duty UI which most support multiples platforms, an MVVM desgin pattern becomes helpful.

Have in mind that each of this will force you to organize your project on a specific way.

Here is some reading for you:

.Net Design Patterns.

Design Patterns.

Object Oriented Design.

Hope this helps.

share|improve this answer