Organizing program code



  • I have been working on a test program that is slowly growing more and more complicated. Right now, there are four main segments:

    The main program
    A graph data structure
    A path finding routine (A*)
    A binary heap structure (to support the path finding)

    In the Visual Studio I had the ability to organize the code either in a series of folders or break the program out into a series of DLLs.

    Are there any recommendations from the folks here on how to organize the program code?



  • You can do that in any other development environment and IDE too. qmake, for example, supports both subprojects (use the subdirs template) and subfolders (all in one project, but nicely organized).

    DLLs are not always necessary. You can break your code into static libs too, and link them into your final application. This works well for windows too.



  • I would move the code to subdirectories and make one executable or break it into libraries. One advantage of libraries is, if your projects gets bigger, you can test seperatly and fix seperatle, without building all at once.
    I personally don't like static libraries, as it's just a workaround of making one bigger project. Ok, it reduces rebuild time, but for splitting (in my opinion) dlls are better.



  • I’d actually suggest against using libraries if they do not serve any purpose: you have public API or have several binaries using same library. Single binary just makes stuff easier for everyone.

    For large projects I’d suggest using something else than qmake. I use cmake, crossplatform make.



  • I would rather divide the code into different subdirectories.



  • I was thinking that static libraries would be easier to work with (for the testing reasons noted above).

    But, now I'm curious about the different directories. When I view the project files, all of the files are grouped without regard to directory unless I view the file system. Is this how people view the sub folders?

    I also haven't been able to locate any sort of SUBDIR template on my installation of Qt. Is this an add-in that needs to be downloaded?



  • @cazador7907

    Qt creator handles subdirectories so every part of the application is divided using subdirectories.

    If the project is Qt-big then I think it should be modularized as the "Trolls are currently working for Qt 4.8":http://labs.qt.nokia.com/2010/10/26/qt-is-going-modular/ but for small/medium project I think subdirectories are good :)



  • Thanks all for you posts. I now understand sub folders.



  • You are welcome :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.