Projects Folder Structures Best Practices
Tags: cleancode, softwareengineering, programming, coding
Published: 2021-08-07 16:13:45

Structuring a solution’s folder is one of the first steps toward starting any software project. If you want to have a good structure with a good separation of tasks, you should be familiar with best practices.
For this purpose, one of the good references which can be used is **Github's good projects’ repositories**.

**Why does folder structure matter?**

**1-** It makes it easier to understand the structure of the project, especially for new developers when they join a new team.

**2-** It helps to separate **deployment** from **application** codes ( test codes vs application codes)

**3-** defining different categories for different objects(DTOs, Contracts, Filters, etc)

**4-** defining categories for various assets which can be set access permission or applying some other concerns on them for better management.




Well, so far we understand the importance of the folder structure of software project solutions.
Important to keep in mind, in a microservice architecture, we may have different folder structures because according to the size of the project or other concerns (framework, language, etc), we may see different structures. but in most cases, you could use this structure for your projects.

**Let’s check an example**
Here We are going to define a folder structure from scratch. In this example, I am going to use **Microsoft Visual Studio** as IDE, but the concept is the same if you want to use different IDE or languages.

First of all, create a repository on Github with the showed properties

![github repo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5lu350cj8zmo0qjv2iq2.png)

As you create your repository, the next step is to clone the project on your local system. Open Visual Studio, select **Clone repository** from the File menu in the opened window, paste the Git URI and click on the **Clone** button.

you will see the existing items in the solution explorer panel

![solution](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nrgsy27bty2urrujyc81.png)

As you can see in the below image, select **Project…** from the **File** menu, then select **ASP.NET Core Empty** project type.(obviously, you can select your own project type)

![folder structure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gx1hmu3g7we4h6febpqt.png)

In the **Configuration** window, set the properties and click on the **Next** button
![visual studio](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mykszfbpcxtzvp197whd.png)

Now, I want to use a **Git** command to create a **.sln** file for our solution, if you haven’t installed **GitBash** on your local system, use this [link](https://git-scm.com/download/win) to install.

Git is a set of command line utility programs that are designed to execute on a 
Unix style command-line environment. [ReadMore](https://www.atlassian.com/git/tutorials/git-bash#:~:text=At%20its%20core%2C%20Git%20is,in%20Unix%20command%20line%20terminals.&text=In%20Windows%20environments%2C%20Git%20is,of%20higher%20level%20GUI%20applications.)

Open the cloned folder in the FileExplorer.
![ww](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d7cvsin5ctvzmpmj8l8l.png)

As the next step, in the opened Window highlight the address bar and type CMD, then hit enter; The **Command Prompt** will be shown, type the command in order to create a **.sln** file

**dotnet new sln**

![gitbash](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ks8a1grhr2cdo9pwyoru.png)

To open with the Visual Studio, double click on the newly created solution file. You would have a solution with this structure if you have followed the previous steps.

![ssss](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x5sanilub4uk4wyhwm5d.png)

Open the root folder and create two folders besides the solution file (**src** and **test**)

![structure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c8ti04hwq3kmjhjr0f2j.png)

From now on every project which related to this solution should locate inside the **src** folder and all the test project should locate inside the **test** folder.

Here you can add all other projects according to your needs (*If you use Visual Studio as IDE, take into consideration that the creation of a folder in Visual Studio won't create a physical folder, and you need to create it manually.*)

![visual project](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r8g9ckotdql2xunup5u8.png)

You also may need to add other folders besides your project like:
**docs**, **tools**, **releases**
![conclusion](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/36b6e1c76mpk2rke2k3b.png)

**Conclusion**
Structuring folders in a solution is one of the most important steps in software project implementation.
*A good beginning makes a good ending*

Follow me on [Medium](https://m-qafouri.medium.com/)

Maybe you like :
[Writing logs into Elastic with NLog , ELK and .Net 5.0](https://dev.to/majidqafouri/writing-logs-into-elastic-with-nlog-elk-and-net-5-0-246c)