Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looking for Suggestions on Microsoft Visual Studio Solution and Project Naming Conventions

There doesn't seem to be any tried and true set of best practices to guide you on how to setup your solutions, projects and the assemblies they output. Microsoft seemed to have tried back in the VS.net days, but they have since retired this content. For every method I read about I read another that claims the opposite is better, or a post that only concerns itself with "if only Microsoft would..." but really provide no solutions.

It appears there are many ways to do this that all seem to work for various groups in their situations, therefore I thought I would ask what conventions YOU use and why they work for YOU in your situation.

I hope that this will provide several good conventions for different situations, small development groups and projects to large diversely located development groups and projects.

What conventions do you use to...

  • name your solutions, and why?
  • name your projects, and why?
  • name your assemblies, and why?
  • know when to create a new project or add to an existing project, and why?
  • know when to split up a solution into smaller solutions, and why?
  • know when to break up a project into multiple projects, and why?

Just to be clear, the WHY is just as import as the HOW in these answers. There are many answers posted on the how here and other places, very few say why they use one convention over another.

like image 781
Rodney S. Foley Avatar asked Oct 06 '10 16:10

Rodney S. Foley


People also ask

What is project name and Solution name in Visual Studio?

A project is contained within a solution. Despite its name, a solution isn't an "answer". It's simply a container for one or more related projects, along with build information, Visual Studio window settings, and any miscellaneous files that aren't associated with a particular project.

What are naming conventions in Visual Basic?

When you name an element in your Visual Basic application, the first character of that name must be an alphabetic character or an underscore. Note, however, that names beginning with an underscore are not compliant with the Language Independence and Language-Independent Components (CLS).

What is naming convention in project management?

Project naming conventions include a standard format for the name and unique identification of each project, and standard identification for each project deliverable. The naming conventions also include version control attributes for both project management and software development (engineering) documentation.


2 Answers

That's a very broad question, but a good one. I will start with a simple structure that I use for ASP.Net web projects (MVC will look completely different).

Solution naming isn't a big deal to me. I tend to create solutions for a specific purpose, and add existing projects to the solutions. If your solution is over 15 projects (just a rough number) consider adding some of those projects as references. Most people don't need to work on more than 15 projects at a time.

Project Naming is a big deal to me.

// class library that supports the site itself and abstracts
// more complicated UI logic into a separate place
Company.ProductName.Web;

// website
Company.ProductName.Web.UI;

// main business object library for product
//
// of course, you can have as many of these as needed.
Company.ProductName;

I try to use enough folders in my projects so that all files in a folder can easily be viewed without scrolling the solution explorer.

My typical web project looks something like this. Note the different in casing to represent namespaced/compilable resources versus those that are not.

  • client (css, javascript)
  • config (private, custom config files, if any)
  • Content (Master Pages, ASPXs and ASCXs, broken into logical folders)
  • Handlers (ASHXs and such)
  • images
  • MSBuild (build scripts)
  • WebServices (these should ONLY be small services that are directly related to the site in question. Otherwise, break them into a separate project).

I've started using partial classes more and more to create comprehensive classes that can do many things without having the code be cluttered. For example, I recently created a web service whose single purpose is to return JSON to the client, but the logic is spread across almost a dozen partial classes to organize it better.

Hope that gets you started.

like image 176
Tim M. Avatar answered Sep 27 '22 19:09

Tim M.


In our case we keep our project names quite identical to namespaces that we chose for particular assembly. That way it becomes easy to map location of a class file in physical folder. For example - CompanyName.BusinessLine.BusinessService or CompanyName.Framework.Security. So if a developer is looking at CompanyName.Framework.Security.Cryptography.cs, he can immediately figure out the project and open that project.

like image 21
Pradeep Avatar answered Sep 27 '22 17:09

Pradeep