|
|
|
|
|
|
|
To consider some examples, the header file SCDTL_1.H contains basic data structures and definitions for the SCDTL system. There is no INDIA_1.H, because the Indian civil calendar system does not require any data structures or definitions beyond those in the basic system. |
|
|
|
|
|
|
|
|
The header INDIA_2.H contains the function prototype definitions for the Indian civil calendar system, just as the header ISLAM_2.H contains the function prototypes for the Islamic calendar. |
|
|
|
|
|
|
|
|
The Maya calendar system contains no special dates in the Western sense of a "day of observance," so the MAYA_3.H header file instead contains global variables usable in a main application program. |
|
|
|
|
|
|
|
|
The basic SCDTL system uses other numbers to cover specific applications. These numbers are discussed in Chapter 4. |
|
|
|
|
|
|
|
|
1.6.3
Legibility Considerations |
|
|
|
|
|
|
|
|
The style adopted in this book is one which emphasizes clarity and simplicity. Function names are typically long enough to be self-explanatory, rather than abbreviated to gibberish, as is the usual C practice. |
|
|
|
|
|
|
|
|
Procedural statements and algorithms are kept as simple as possible, even where (especially where) a more compact form is possible. |
|
|
|
|
|
|
|
|
I believe that C contains a number of atavistic features which flaw its design. As a result, SCDTL uses a standard subset of features and entirely avoids others. |
|
|
|
|
|
|
|
|
Arrays are used in SCDTL for the single purpose of storing groups of precalculated values within functions to save execution time. No explicit effort is made to avoid the C convention of zero indexing. |
|
|
|
|
|
|
|
|
Unions are used only in the single application area of PC and DOS system date and time. |
|
|
|
|
|
|
|
|
All conditionals are implemented by the if, ifelse or switch statements. The else-if is not used, and the illegible abomination, question markcolon, is banished. |
|
|
|
|
|
|
|
|
Labels and goto are, needless to say, never used. |
|
|
|
|
|
|
|
|
Loops are implemented with for where the looping is controlled by a count and with while where looping is controlled by a condition. The do construct is a dangerous "execute-test-loop" structure, which can always be replaced by the safer and more legible while. |
|
|
|
|
|
|
|
|
The switch statement is a dangerously flawed construction in C and is therefore used sparingly and grudgingly only in those cases where the equivalent nested if construction would be unwieldy and difficult to read and maintain. The convention is used that a break statement is used after every case, forgoing the clever or efficient fall-through in favor of explicitly declaring all relevant variable assignments under each case. |
|
|
|
|
|
|
|
|
Indentation is followed strictly. Each level of code is indented to the character position following the token word, and all alignment is exact by column. Thus, the if-else construction is indented as follows: |
|
|
|
|
|