2013-07-18

Source code directories structure

As an experieced coder, one of things you would do in any new project is to decide on the structure of the source code directories. Basically, there are two main ways to organize your code: flat or hierarchical. Suppose you have three broad categories of code: one for UI, one for Data, and one for Database in our app named HelloApp. Suppose that the Ui contains further subdivisions into Login, Dashboard, Settings.

For their hierarchical structure, such as that used for java packages, we would have a src directory like:
src/app
src/app/gui/login
src/app/gui/dashboard
src/app/gui/settings
src/app/data
src/app/database

If you are using a hierarchy your build tool needs to be able to recurse through a directory tree (more about build tools in later posts). Java build tools such as thise in netbeans or eclipse are able to handle this. You may also want to look at the Apache Ant build tool if you are not a big fan of IDEs

For C# projects using visual studio, the directory structure is more or less flat.
A solution directory is created for HelloApp and a project directory is created. All the source files are in the project directory by default. Structure is

HelloApp/HelloApp   i.e. ( solution directory/project directory )

The default is to place all the source files inside HelloApp/HelloApp directory

The IDE provides an organized view of the source using the explorer view. If you still want to create a hierarchical structure, you can do it using the [Add Folders] menu option in the project directory. If you add folders, the directory structure will become: 

HelloApp/HelloApp/gui/login
HelloApp/HelloApp/gui/dashboard
HelloApp/HelloApp/gui/settings
HelloApp/HelloApp/data
HelloApp/HelloApp/database

The MSBuild tool is able to handle recursing through a directory tree.


No comments:

Post a Comment

Github CoPilot Alternatives (VSCode extensions)

https://www.tabnine.com/blog/github-copilot-alternatives/