Search code examples
c++project-managementproject-planningcode-organizationproject-organization

Looking for a sample C++ program for learning how to start up a project


I've learned the most basic of C++ but I feel like I don't know how to organise the code and start up a C++ project. I've searched for guides about project/code organization without very much luck.

So I want to find a litle well-coded real program to see how is it organised, but I find nothing. Do anyone know a real well-organised program in C++? Preferably open source, terminal based and unix-only.

Thanks.


Solution

  • This is mostly dependent on a couple of things:

    1. Supported platform(s): this will push or pull you toward different code structure if you abstract the different platforms differently.
    2. Build system: stuff like CMake, qmake, autocr*p, Ant, Bjam, jam, etc...
    3. IDE: this won't be a show-stopper, but still could decide number 2.
    4. Is it a GUI or console only or library project: this will IMO force your to structure your program differently, especially if you obey the unspoken rule of splitting GUI and "processing" functions. A library will need a nice API header set, where another (non-library API bound) project will let you be free in that regard.
    5. What do you think is best? If you don't feel right in a certain set-up, don't use it and refactor (if it doesn't take all your time of course...

    I have just started a humble C++ project, with a small platform abstraction layer, maybe that can give you some hints/suggestions. Source code is viewable here (it is quite nonfunctional now and uses qmake to build): http://sourceforge.net/p/ambrosia/git -> browse

    What I did: - One platform abstraction header which provides platform-independent function definitions which are implemented in (currently) one source file per platform. - One global header including several headers which contain stuff needed virtually everywhere. - Some subfolders logically organized per goal of the code.