-------------------------------------------------------------------------
2610 Programming Standards
-------------------------------------------------------------------------
Copyright 2010 Richard J. Gaydos
-------------------------------------------------------------------------
Obviously, the program must "work", that is, produce the required output.
However, you MUST also follow ALL of the following rules to meet my
standards.
Your program MUST be EXTREMELY well-structured (see following rules).
A completely-working program that does not meet my "well-structured"
requirements WILL receive the grade it deserves: ZERO.
Rules for a well-structured program:
/*-------------------------------------------------*/
/* */
/* First comment box rule */
/* */
/*-------------------------------------------------*/
1. You MUST liberally use THIS comment box:
/*-------------------------------------------------*/
/* */
/* Comment */
/* */
/*-------------------------------------------------*/
/*-------------------------------------------------*/
/* */
/* Second comment box rule */
/* */
/*-------------------------------------------------*/
2. Comment boxes MUST NEVER exist right next to code.
/*-------------------------------------------------*/
/* */
/* Third comment box rule */
/* */
/*-------------------------------------------------*/
3. Write ONLY in the middle line of the box,
starting two positions after the asterisk.
/*-------------------------------------------------*/
/* */
/* Fourth comment box rule */
/* */
/*-------------------------------------------------*/
4. As well as having a comment box before each section
of code, you MUST have an extra FIRST box that
looks like
/*-------------------------------------------------*/
/* */
/* Lab n Title */
/* */
/* Your Name(s) */
/* */
/*-------------------------------------------------*/
/*-------------------------------------------------*/
/* */
/* Variable name rule */
/* */
/*-------------------------------------------------*/
5. Variable names MUST be chosen to accurately reflect contents.
Abbreviations MUST be pre-approved by ME !!!
/*-------------------------------------------------*/
/* */
/* main module rule */
/* */
/*-------------------------------------------------*/
6. main Module MUST look like this:
Notice that statements start in column ONE!!
return-type main ( )
{
statement;
statement;
statement;
}
/*-------------------------------------------------*/
/* */
/* Declarations rule */
/* */
/*-------------------------------------------------*/
7. Storage declarations MUST be LOGICALLY organized and
look like this:
int variable,
variable,
variable;
float variable,
variable,
variable;
/*-------------------------------------------------*/
/* */
/* cout rule */
/* */
/*-------------------------------------------------*/
8. "cout" statements MUST follow this format:
cout << item
<< item
<< item
<< item;
/*-------------------------------------------------*/
/* */
/* cin rule */
/* */
/*-------------------------------------------------*/
9. "cin" statements MUST follow this rule:
cin >> item
>> item
>> item
>> item;
/*-------------------------------------------------*/
/* */
/* if rule */
/* */
/*-------------------------------------------------*/
10. "if" constructs MUST be indented as follows:
if (condition)
{
statement;
statement;
}
else if
{
statement;
statement;
}
else
{
statement;
statement;
}
/*-------------------------------------------------*/
/* */
/* switch rule */
/* */
/*-------------------------------------------------*/
11. "switch" statements MUST look like this:
switch (expression)
{
case value: statement;
statement;
break;
case value: statement;
statement;
break;
default: statement;
statement;
break;
}
/*-------------------------------------------------*/
/* */
/* First Loop rule */
/* */
/*-------------------------------------------------*/
12. "while" loops MUST look like this:
while (condition)
{
statement;
statement;
}
/*-------------------------------------------------*/
/* */
/* Second Loop rule */
/* */
/*-------------------------------------------------*/
13. "for" loops MUST look like this:
for (initial; test; increment)
{
statement;
statement;
}
/*-------------------------------------------------*/
/* */
/* Nesting rule */
/* */
/*-------------------------------------------------*/
14. If a logical construct exists INSIDE of another logical construct, the
indenting rules MUST extend to the nested construct as well.
Comments inside a loop MUST be indented in line with statements.
/*-------------------------------------------------*/
/* */
/* Prototype rule */
/* */
/*-------------------------------------------------*/
15. Prototypes must look like:
return-type Function-Name (type,
type,
type);
/*-------------------------------------------------*/
/* */
/* Another module rule */
/* */
/*-------------------------------------------------*/
16. Modules MUST look like this:
Notice that statements start in column ONE!!
return-type module (type parameter,
type parameter,
type parameter)
{
statement;
statement;
statement;
}
/*-------------------------------------------------*/
/* */
/* Second module rule */
/* */
/*-------------------------------------------------*/
17. Modules MUST be preceded by a comment box.
/*-------------------------------------------------*/
/* */
/* struct rule */
/* */
/*-------------------------------------------------*/
18. "structs" MUST look like this:
struct Name
{
type variable;
type variable;
type variable;
type variable;
};
/*-------------------------------------------------*/
/* */
/* class rule */
/* */
/*-------------------------------------------------*/
19. "classes" MUST look like this:
class ClassName
{
private:
type variable;
type variable;
type variable;
type variable;
public:
ClassName (); is the contructor ();
~ClassName (); is the destructor ();
return-type ClassName :: Method ();
return-type ClassName :: Method ();
return-type ClassName :: Method ();
};