Thread: How to organize the big C++ project

  1. #1

    How to organize the big C++ project

    Hi people,
    I have a C++ project with 6 Classes and each class have about
    10 member function, and each member function code with about
    more than 3 pages.
    I have created each file for each class implementation(implement_file.cpp) . but the file is still big since 10 member functions x 3pages/per 1 member function = 30 pages for a file.
    This is kinda a huge implementation file.
    Is that any other ways to implement to eliminate the file size?
    For example:

    Header file: interface.h
    | all C++ classes declaration here|

    Implement file: classA.cpp
    | #include "interface.h"
    | implement for class A with 10 member functions and
    | 30 pages for 10 function.
    Implement file classB.cpp
    |#include "interface.h"
    | implement for class B with 10 member function.
    Can you guys, experienced programmer know how to redesign or
    modulize the big project like this into easy manageable files?
    Does it common to code a class with 100 pages for 1 file/per one class???
    Thanx a lot for your sugesstion or advice.

  2. #2
    Registered User
    Join Date
    Jun 2002
    Well, just my opinion here...

    I find it is more difficult to keep track of a large number of files with a little bit of code in each one. With the prevalence of text editors that have decent Find/Replace functions, many of the disadvantages of large files are reduced. Other disadvantages, such as poor legibility, spring more from the fact that there is a lot of code to look through and can in fact be made worse by having to look through a bunch of files to find the part that you're interested in.

    Some possible solutions: templates (if your functions do similar things), shared library compilation (doesn't help with the source file size issue but can help with organization), or if your classes are similar to each other you might think about an inheritance structure, which can cut down on the amount of source code.

    Don't hesitate to post if you need more concrete suggestions, but you'll need to post example code if you do.
    Claus Hetzer
    Compiler: Borland 5.5 (on Windows)
    Solaris CC (on Unix)
    Known Languages: C++, MATLAB, Perl, Java

  3. #3

    Unless you're doing graphics programming in those functions I think you may be doing something wrong - 3 pages per function is too much.

    What, do you got an S-load of switch:case statements??

    We would have to look at your code, maybe just post one of your longest functions here, and others could take a look because there is probably standard Library routines that could replace whole sections of your code.
    My Avatar says: "Stay in School"

    Rocco is the Boy!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Project Help please!
    By black_hole??? in forum C++ Programming
    Replies: 4
    Last Post: 04-28-2009, 12:55 AM
  2. Big and little endian
    By Cactus_Hugger in forum C Programming
    Replies: 4
    Last Post: 10-12-2005, 07:07 PM
  3. Game Independent Anti-cheat Project Needs Programmers
    By GIA Project Lea in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 09-15-2005, 07:41 PM
  4. How to add a file to a project in bloodshed.
    By Smeep in forum C++ Programming
    Replies: 4
    Last Post: 04-22-2005, 09:29 PM