Hi everyone,
I'm not so sure if this belongs in here or in computer science but I think as I want to use c++ this may be the place.
I was wondering if anyone could point me towards some tutorials/references or books on methods for approaching the design of larger projects.
I keep finding that part way through a development of a project I have to change some amount of the functions to support new features I want and editing classes and this sometimes causes me to have to "hack" code to get some things working how I expected again. I have tried various approaches to debugging by utilizing visual studio's built in debugger to watch variables and using both a debug log file generator in code to record to a file the results of various operations and also using #ifdef tags to mark debugging console printouts per module i.e. as below (code here is typed not copied pasted so its to demonstrate the method and may not be totally correct code but I hope its right)
//using my errorLogg function
/*pass typedef'd struct of openGL settings to my openGL class which will then call the init functions i need set up view mode, pixel format, required features etc*/
if(!initOpenGL(oglSettings))
{
errLog(OPENGL_INIT_FAIL);//OPENGL_INIT_FAIL is an enum value i have for my errLogger
cout<<"Error: "<<enumToInt(OPENGL_INIT_FAIL)<<endl;
exit(-1);
}
//using #ifdef's
#ifdef _OGL_DEBUG_
if(!initOpenGL(oglSettings))
{
cout<<"OpenGl failed to initilise\n";
}
#else
if(!initOpenGL(oglSettings))
{
exit(-1);
}
#endif
I think the error log approach is more effective as I can provide more information and of course it does not require a recompile to simply debug, but as I have no real software experience being self taught I don't know how its done. I've seen both approaches used in places in code I looked at.
My code goes from usually quite neat and tidy to a complete mess and I find as the project develops I spend more and more time finding the right variables I want to use or functions and get lost. I also find that I spend more and more time adding error enums to my error logger which becomes a massive switch statement.
Recently I have also looked into exceptions but have not used them as i'm not comfortable with them, would it be a good step to use them in place of or in conjunction with my error logger? or in the #ifdef where I have no debugging set throw an exception when the else version is used so I still get indication of an error?
Would anyone consider these design issues or a lack of experience as I have only done smaller code projects before and need to learn by experience what to use and where because if so I guess I need a heck of a lot more experience?
The design approach i'm taking is a bottom up design (i think thats the correct name) in that i start with basic functionality and then expand features as i go, i tried a top down design where i knew the features i wanted but then got lost as where to start to impliment everything seemingly at once.
Any help or advice on any of the above items would be greatly appreciated and if this is the wrong place for my topic could you advise where to move it and how to delete this thread as I couldn't get a previous thread to delete only edit :(
Again thanks for your time and effort in helping me