Skip to content

This repository has the purpose of creating a hierarchical tree file organization system standard for small to medium size projects. Each folder sorted by the programming language will contain a file structure template that can be cloned or downloaded to start new projects. I have come to a project structure that shall avoid confusion being as s…

License

Notifications You must be signed in to change notification settings

AlexDCode/Software-Development-Project-Structure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Software Development Project Structure

file-tree

Introduction

Programmers πŸ‘¨πŸ»β€πŸ’» had different practices on how they decide to structure their codeπŸ—„πŸ“‚πŸ“šπŸ“. This repository has the purpose of creating a hierarchical tree file organization system standard for small to medium size projects. Each folder sorted by the programming language will contain a file structure template that can be cloned or downloaded to start new projects.

After some research, I have come to a project structure that shall avoid confusion being as simple as possible and should keep your code clean, neat, structured, and clutter free. The file structure system is modular and suited to modern standards, therefore you can add or remove files and folders to tailor it to a particular project or task. Each folder has its own explanation in this guide and more documentation in the folder itself.

File System Characteristics

The most elemental file structure is made of several components to place the source code, private and public headers, asstets (images, fonts, sounds, etc.), libraries, debugging files, test files, a .gitignore file, and a documentation file. The Integrated Development Enviroment (IDE) can add extra configuration files. A simple structure for a C++ project named Project_Name would have a similar layout to this tree:

Project_Name/
β”œβ”€β”€ debug/
β”œβ”€β”€ include/
β”‚Β Β  β”œβ”€β”€ Project_Name/
β”‚Β Β  β”‚Β Β  └── public_headers.h
β”œβ”€β”€ lib/
β”‚Β Β  └── lib_A/
β”œβ”€β”€ src/
β”‚Β Β  β”œβ”€β”€ assets/
β”‚Β Β  β”‚Β Β  └── image_A.jpeg
β”‚Β Β  β”‚Β Β  └── font_A.ttf
β”‚Β Β  β”œβ”€β”€ main.cpp
β”‚Β Β  └── private_headers.h
β”œβ”€β”€ tests/
β”‚Β Β  └── alpha_version/
β”œβ”€β”€ C++.gitignore
└── ReadMe.md

Let's break the structure down to understand its hierarchy.

1. Project_Name/

The Project_Name/ is the project parent directory where all the related files are located from source to binaries. The name of the folder should be Project_Name. The folder would contain the source code, libraries, assets, debugging, testing, and release files. Also, the folder in Project_Name/include/ should be named the same as the Project_Name/.

2. Project_Name/debug/

The Project_Name/debug/ directory includes the compile, debugging, run, and binaries files of the program. Is the test directory for change in the program and where all the cache files are placed on compiled, debugged, and runned. The folder tree for a debugging session with VS Code and Clang++ would look like

Project_Name/
β”œβ”€β”€ debug/
β”‚Β Β  β”œβ”€β”€ main.dSYM/
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ Contents/
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ Resources/
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ DWARF/
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ main
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── Info.plist
β”‚Β Β  └── main

3. Project_Name/include/

By convention, the Project_Name/include/ directory is for header files, but modern practice suggests that include directory must strictly contain headers that need to be exposed publicly. An interesting thing to note here is the use of another directory inside the Project_Name/include/ directory with the name same as that of your project. The reason to do this is to give a sense of specification when someone tries to use your library and public headers. Therefore, instead of using a generalized

#include <public_header.h>

we need to specify that the header file that we are includding is exposed publicly on the project giving a more intuitive and clean code as

#include <Project_Name/public_headers.h>

The header file in the Project_Name/include/Project_Name/ directory will be exposing those functions and classed that can be publicly called and used by someone using your library. The folder tree would look like

Project_Name/
β”œβ”€β”€ include/
β”‚Β Β  β”œβ”€β”€ Project_Name/
β”‚Β Β  β”‚Β Β  └── public_headers.h

4. Project_Name/lib/

The Project_Name/lib/ directory consists all the third party libraries that are needed by your project. Usually if you look into any of the third party libraries present here, they would be following a similar structure that you are using for your project. A point to note is there are two ways of using third party libraries in C++ β€” static and dynamic. This lib directory is only for static ones. The folder tree would look like

Project_Name/
β”œβ”€β”€ lib/
β”‚Β Β  β”œβ”€β”€ lib_A/
β”‚Β Β  └── lib_B/

5. Project_Name/src/

The Project_Name/src/ directory contains all the source code and the header files that are private and for internal use only. All the code that your project consists of must go in here. Other directories have the cmoponents needed to run, debug, and release the program but the src directory has the program itself. The folder may have subdirectories to separate functions, components, and other files. The folder tree would look like

Project_Name/
β”œβ”€β”€ src/
β”‚Β Β  β”œβ”€β”€ assets/
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ images/
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── image_A.jpeg
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ fonts/
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── font_A.ttf
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ sounds/
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── sound_A.mp4a
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ video/
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── video_A.mp4
β”‚Β Β  β”œβ”€β”€ utils/
β”‚Β Β  β”œβ”€β”€ modules
β”‚Β Β  β”œβ”€β”€ main.cpp
β”‚Β Β  └── private_headers.h

a) Project_Name/src/assets/

The Project_Name/src/assets contains all the media files needed by your project. The folder must contain subfolders clasifying the files by the media type, i.e. images, fonts, sounds, etc. The folder tree would look like

Project_Name/
β”œβ”€β”€ src/
β”‚Β Β  β”œβ”€β”€ assets/
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ images/
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── image_A.jpeg
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ fonts/
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── font_A.ttf
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ sounds/
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── sound_A.mp4a
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ video/
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── video_A.mp4

b) Project_Name/src/utils/

The Project_Name/src/utils/ directory contains code snippets and functions needed throughout the source code. They are like small functions to build bigger and more complicated code. Sometimes it is also called modules. The folder tree would look like

Project_Name/
β”œβ”€β”€ src/
β”‚Β Β  β”œβ”€β”€ utils/
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ average.cpp
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ average.h
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ standard_deviation.cpp
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ standard_deviation.h
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ graph.cpp
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── graph.h

6. Project_Name/tests/

As the name suggests, code for unit testing is kept in this directory. Different versions of the programs such as alpha or beta developer versions are stored and tested in this directory. The files in this directory should be pre release, not finished code. When the code revision is finished it can be moved to a release directory with a version number. The folder tree would look like

Project_Name/
β”œβ”€β”€ tests/
β”‚Β Β  β”œβ”€β”€ alpha_version/
β”‚Β Β  └── beta_version/

Documentation

Each project should have a ReadMe.md file or equivalent in its parent directory Project_Name/. This file would explain the functionality of the project, overview, installation, and usage. If the project is big a table of contents is recommended. The ReadMe.md file at the parent directory is like the user initial guide, but for further documentation you should place more details about the design and technical functionality on the Project_Name/docs/ directory. This documentation can include a full user manual, a document describing the different functions, a list of the third party libraries and assets, an explanation of the data files, and the testing results. The Project_Name/etc/ directory includes configuration files for the project. The Project_Name/data/ directory includes the data files for the project such as databases, cdv files, and others. The .vscode contains the configurations files for the VS Code IDE.

Hierarchical Files Structures Trees for VS Code

C++ File Structure Tree

Project_Name/
β”œβ”€β”€ .git/
β”œβ”€β”€ .vscode/
β”‚Β Β  β”œβ”€β”€ launch.json
β”‚Β Β  └── tasks.json
β”œβ”€β”€ data/
β”œβ”€β”€ debug/
β”œβ”€β”€ docs/
β”œβ”€β”€ etc/
β”œβ”€β”€ include/
β”‚Β Β  └── Project_Name/
β”‚Β Β      └── public_headers.h
β”œβ”€β”€ lib/
β”œβ”€β”€ src/
β”‚Β Β  β”œβ”€β”€ assets/
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ fonts/
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ images/
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ sounds/
β”‚Β Β  β”‚Β Β  └── videos/
β”‚Β Β  β”œβ”€β”€ utils/
β”‚Β Β  β”œβ”€β”€ functions_code.cpp
β”‚Β Β  β”œβ”€β”€ main.cpp
β”‚Β Β  └── private_headers.h
β”œβ”€β”€ tests/
β”‚Β Β  β”œβ”€β”€ alpha_version/
β”‚Β Β  └── beta_version/
β”œβ”€β”€ C++.gitignore
└── ReadMe.md

Python File Structure Tree

Project_Name/
β”œβ”€β”€ .git/
β”œβ”€β”€ .vscode/
β”œβ”€β”€ data/
β”œβ”€β”€ debug/
β”œβ”€β”€ docs/
β”œβ”€β”€ etc/
β”œβ”€β”€ include/
β”‚Β Β  └── Project_Name/
β”‚Β Β      └── public_functions.py
β”œβ”€β”€ lib/
β”œβ”€β”€ src/
β”‚Β Β  β”œβ”€β”€ assets/
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ fonts/
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ images/
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ sounds/
β”‚Β Β  β”‚Β Β  └── videos/
β”‚Β Β  β”œβ”€β”€ utils/
β”‚Β Β  β”œβ”€β”€ functions_code.py
β”‚Β Β  β”œβ”€β”€ main.py
β”‚Β Β  └── private_funtions.py
β”œβ”€β”€ tests/
β”‚Β Β  β”œβ”€β”€ alpha_version/
β”‚Β Β  └── beta_version/
β”œβ”€β”€ Python.gitignore
└── ReadMe.md

Contributing

This is an open source library, all contributions are welcome following the next guidelines

  • Each new file tree should be in its own programming language directory and following the standards explain in this document, any improvement to this methodology can be proposed in the same Pull Request as an Enhancement.md file (optional).
  • In a Changelog.md file include details of the changes and improvements.

References

C++ application development ( Part 1 β€” Project structure )

About

This repository has the purpose of creating a hierarchical tree file organization system standard for small to medium size projects. Each folder sorted by the programming language will contain a file structure template that can be cloned or downloaded to start new projects. I have come to a project structure that shall avoid confusion being as s…

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published