Category Archives: Code

Solutions, projects and directory structure

A while ago I had a discussion with a colleague on what the structure of our code repository ought to be. At the time, I couldn’t find the words to explain why I prefer one strategy over another, so I’ve given it some more thought.

In this case we’re talking about several Visual Studio Solutions (.sln) and their C++ projects (.vcxproj). If I were to choose a directory structure, my considerations would be as follows.

Ownership and containment

Solution

A solution contains projects that it may or may not own. I expect a solution like MyApplication.sln to contain a project MyApplication.vcsproj. The solution owns this project, the main project. The project could have dependencies on other projects of course. These dependencies are either specific for this project, or generic and reusable. The solution contains all projects that the projects it owns directly or indirectly depend on. I.e. My Applicaiton depends on MyApplicationLib, which in turn depends on GenericLib. The solutoin contains all three projects. It may seem obvious, but it’s quite common to find a project that depends on a library that is not included in the solution, causing a linker error unless you built this additional dependency manually beforehand. Not pretty.

MyApplication

Continue reading

Testing and refactoring

“When you don’t really know how long it is going to take to add a feature and you suspect that it will be longer than the time you have, it is tempting to just hack the feature in the quickest way that you can. Then if you have enough time, you can go back and do some testing and refactoring. The hard part is actually going back and doing that testing and refactoring.”

— Michael C. Feathers, Working effectively with legacy code (59)