Results 1 to 5 of 5

Thread: Planning the general structure of a C++ program

  1. #1
    Join Date
    Aug 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Planning the general structure of a C++ program

    I'm very much a newbie at OO C++ programming, and I'm wondering if anyone has links to articles/guides/whatever discussing the initial planning of a C++/OO program, or some first-hand tips on doing so.
    At the moment I just tend to dive right in without really thinking about the overall structure (classes, instances, class and header files, how objects exchange data, etc... everything really), and I end up with some fairly mixed results.
    Usually I end up restructuring the whole program a few times before I'm happy with it, and I'm not too worried about it at the moment, but I think it would be better to develop some good practices before attempting anything larger.

    Maybe it starts with drawing diagrams, or maybe just writing a list of objects... I don't know.
    Any recommended reading?

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Planning the general structure of a C++ program

    Hi, i'm "kind of" in a similar situation, i know C++, i learn Qt but the progress is not as fast as i wanted to be.

    From my "experience" (learning experience) it isn't a book to teach you that (you should read many and practice, do exercises...), but i really recommend the C++ programming language written by Bjarne Stroustrup, it contains some chapters about design (i'm not at that chapters yet, so i can't say if i like it or not )

    Anyway, my opinion is that you should read many books, work with libraries that are known to be good (like Qt and Boost) and try to get a programming job, you will learn from experienced programmers (read/answer to forums might compensate a little bit, if you are in a similar situation like me and can't find a job)

  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Planning the general structure of a C++ program

    I don't think it's possible to write perfect code the first time. Code evolves through versions. Sure, I don't just throw code together and hope it works, but I don't spend 6 months doing diagrams either.

    Generally I just sketch the way the app should work and how to code it, then decide which module I'm going to do first. Decide on how I'm going to do that, write it, and then move onto the next. You will usually want additional or modified functionality further down the line in one of your modules, but that's acceptable - you can't think of everything first and lock it in stone.

    Unit tests are also good. You should be writing everything in reusable modules, so it shouldn't be difficult to write something simple to ensure those modules still work how you expect them to. It could easily saves hours of time searching for bugs that appeared versions ago and buried their heads and are now only showing up through other modules.

    It isn't all about coding either, I think you need to use (and learn well) a decent version control application like Subversion(SVN) or GIT (I prefer the former), even if your the only author. They make life easier and save your bacon. Don't be tempted to just copy the odd version to another directory, or zip up the contents.

  4. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Planning the general structure of a C++ program

    Some experience I can share when dealing with complex projects (not only coding projects, but in general).

    A lot of projects seem easy but are complex in nature. Complex doesn't mean it will be difficult but it needs attention.
    I have always learned to study a problem first and think about how to split it up into managable parts.

    Don't set your goal on the completion of the whole project. Set your goal on the completion of one milestone. This way you will be interested in the project much longer because you get a lot more rewards when working on it.

  5. #5
    Join Date
    Jan 2010
    Posts
    63
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Planning the general structure of a C++ program

    I have the following books are excellent to learn from C++ How to Program Fourth Ed by Dietal .I did 14 chapters of this book. Another excellent book C++ Primer by Stanley Lippman 4th ed. I have not gone this book yet. It is even better than first book. For data structures get Data Structures Demystified by
    James Keogh; Ken Davidson.

Similar Threads

  1. Replies: 3
    Last Post: 29th March 2010, 13:41
  2. General: Structure of a Qt mainwindow program
    By kaizimir in forum Newbie
    Replies: 6
    Last Post: 7th September 2009, 18:33
  3. Some advice on how to structure this program?
    By mrwooster in forum Newbie
    Replies: 13
    Last Post: 12th August 2009, 14:24
  4. Compile general C++ program from Qt
    By srinivasj in forum Qt Programming
    Replies: 3
    Last Post: 30th December 2008, 08:19
  5. Big Qt Project planning...
    By blackliteon in forum Qt Programming
    Replies: 9
    Last Post: 8th February 2006, 08:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.