Project / Source Tree Structure
Posted: Mon Sep 19, 2011 8:05 pm
I asked this question before, when I was active on the DBPro Forums and got some interesting responses.
I thought I would also ask here and get your guys' take, as some of you are also professionals who probably use strict standards.
I've always been unsure about the "proper" way to structure my projects, and their source code trees; mostly relating to where I want to store certain information.
In general I like to use Projects, and then split my code up over several files, which hold the code responsible for certain tasks, or "systems". My justification is I want to keep my source code files restricted to a fairly decent size, keep them easy for me to read, and if I want to change something keep them easy to edit. I don't want to waste a lot of time looking through a large source tree for a block of code that I want to change, possibly becoming confused between similar blocks of code (rare problem I guess, but it could happen).
I generally work out of a "Main.pb" file, which houses Xinclude statements, and the main Event Loop. Everything is split off from there, so I would have a source file for the skeleton of my GUI (actual Window / Gadget instantiation and placement) but I may have further includes from that point also, for parts of the GUI that do other things.
My World Editor for my Text RPG for instance, I have my "Windows_GUI" source which builds the actual GUI, but there is also an include file (or will be once I refactor my project for EnableExplicit) which houses a separate Grid Rendering Procedure, and some code related to it, for Rendering the Grid Graphics for my level editing.
---------
I have never used Init() routines, etc in programs before but I know a lot of you do.. Do you generally keep all your variable definitions inside such a Procedure? Do any of you keep them in separate source files? I have often toyed with the idea of dedicated Files for Globals, Constants, Procedures, etc.. But I'm not sure how to strike the right "balance". Obviously I can build Procedures in files related to the systems they control, and obviously any Static/Shared variables can be handled within them.
But on the whole, I'm interested in hearing what other people do, and what they have learned to avoid doing, to prevent problems from cropping up.
I thought I would also ask here and get your guys' take, as some of you are also professionals who probably use strict standards.
I've always been unsure about the "proper" way to structure my projects, and their source code trees; mostly relating to where I want to store certain information.
In general I like to use Projects, and then split my code up over several files, which hold the code responsible for certain tasks, or "systems". My justification is I want to keep my source code files restricted to a fairly decent size, keep them easy for me to read, and if I want to change something keep them easy to edit. I don't want to waste a lot of time looking through a large source tree for a block of code that I want to change, possibly becoming confused between similar blocks of code (rare problem I guess, but it could happen).
I generally work out of a "Main.pb" file, which houses Xinclude statements, and the main Event Loop. Everything is split off from there, so I would have a source file for the skeleton of my GUI (actual Window / Gadget instantiation and placement) but I may have further includes from that point also, for parts of the GUI that do other things.
My World Editor for my Text RPG for instance, I have my "Windows_GUI" source which builds the actual GUI, but there is also an include file (or will be once I refactor my project for EnableExplicit) which houses a separate Grid Rendering Procedure, and some code related to it, for Rendering the Grid Graphics for my level editing.
---------
I have never used Init() routines, etc in programs before but I know a lot of you do.. Do you generally keep all your variable definitions inside such a Procedure? Do any of you keep them in separate source files? I have often toyed with the idea of dedicated Files for Globals, Constants, Procedures, etc.. But I'm not sure how to strike the right "balance". Obviously I can build Procedures in files related to the systems they control, and obviously any Static/Shared variables can be handled within them.
But on the whole, I'm interested in hearing what other people do, and what they have learned to avoid doing, to prevent problems from cropping up.