Page 1 of 1

Modularity: a code with "sections"

Posted: Wed Sep 12, 2007 10:02 pm
by Dräc
I launch an idea stemmed from my professional experience(*).
It’s about enhancing modularity which is a common programming approach.
When someone searches to split his code into modules, by grouping code lines having a strong link together, some problems could occur at the compilation time:
  • - Often, it is because a procedure is not yet known by the compiler but used.
    To avoid this specific situation, we can use the keyword “Declare”.
    - Otherwise, this problem could occur also for structure, interface… declarations.
    The only solution to this situation is to group all the structure, interface… declarations into the same file.
As a consequence, the modularity can be dissolved quickly (or you spend your code time in creating thousand and thousand files)

My suggestion is to give to the compiler this responsibility (hello Fred :) ) consisting in regrouping automatically procedure, structure and interface declarations. (for procedures, I mean that “Declare” keyword are automatically generated)

Two ways:

1- The compilator identified each element by scanning the whole code and build the adequate file before compilation.
2- We use directive keyword to mark the code, like: StructureSection/EndStructureSection
So the compilator knows it need to put each Structure section together before compilation. The order of the concatenation is still the one of the IncludeFile, but it is an advance…

What are you thinking about that? I don’t know if the idea is compatible with the compiler architecture and speed quality, so…

---------------------------------------------------------------------------------
(*)For my job, I use a software to build a model of the studied physical system. The approach is the split the system into sub-systems.
Each sub-system is coded in a specific file.
Each specific file has the same structure, meaning divided into the same number of sections required by the solver software (node declaration, node couplings declaration…).
All the specific files are merged to create the studied system through a main file called Skeleton.
The Skeleton is just a file with the different sections that exist into each specific file.
In each section are implemented only an includefile of each specific file.
By expanded the skeleton, each part of the specific files called in each section from the Skeleton are merged.
When all the sections are processed, we obtain the full code before compilation.