COMP 3430 – Operating Systems
COMP 3430 – Operating Systems
Copyright By PowCoder代写 加微信 powcoder
Programming Standards
This document lists the programming standards that you must follow for the programming questions of your assignments and exams.
Failure to follow these standards will result in the loss of marks.
Each of your program files must begin with a comment block like the following:
//—————————————–
// NAME: your name
// STUDENT NUMBER: your student number
// COURSE: COMP 3430, SECTION: Axx
// INSTRUCTOR: name of your instructor
// ASSIGNMENT: assignment #, QUESTION: question #
// REMARKS: What is the purpose of this program?
//—————————————–
If the purpose of a routine is not self-explanatory, write a prologue comment at the beginning, similar to the following:
//——————————————————
// myRoutine
// PURPOSE: tell me what it does!
// INPUT PARAMETERS:
// Describe those parameters which accept data values.
// OUTPUT PARAMETERS:
// Describe those parameters which return values.
// Include the value returned by the routine if not void.
// Some of these may be the same as the input
// parameters.
//——————————————————
… myRoutine(…)
Parts of the prologue may be omitted if appropriate, e.g., if the routine
has no parameters.
Use blank lines to separate blocks of code and declarations to improve readability. In particular, use blank lines between declarations and other code, and between routines.
Comment blocks of code. Describe why you wrote the code this way, not what each line does. For example:
// Print the results.
printf(“The taxes payable are:\n”);
printf(“Federal tax = %d\n”, federalTax);
Use meaningful but reasonable variable names.
a – Very bad. too short, not meaningful.
averageMark – Good
average_of_all_the_marks_in_the_list – Bad. Too long and wordy.
If a concise variable name does not completely describe the data it stores, add a comment to the declaration with additional information.
Use indentation properly, and align else with the corresponding if for readability. Any readable and consistent style is acceptable. The essential features are that all statements that are nested within another statement must be indented, and that the braces { } must be in predictable and consistent positions. Common styles include:
if-while-else-etc {
stuff-inside
stuff-inside
if-while-else-etc
stuff-inside
stuff-inside
if-while-else-etc
stuff-inside
stuff-inside
Declare all variables at the beginning of a routine and never within a sub-block.
Avoid the use of literal constants (“magic numbers”) in your program. Generally use constant identifiers rather than literal constants in your program. Acceptable exceptions are strings that appear only once in output titles and headings, and small fundamental values. Examples,
sum = 0; literal constant 0 is OK
count = count + 1; literal constant 1 is OK
price = total * 1.07; not proper. Create a named constant like PST_RATE = 1.07.
lastDigit = accountNumber % 10; literal constant 10 is OK in this context (i.e., mod 10 to get the last digit is a well-known practice).
if(codeLetter == ‘R’) not proper. Create a named constant like REFUND_CODE = ‘R’.
Appropriate prompts should always be used for interactive input.
All output produced by your programs must have appropriate titles and headings.
The output of a program should contain a message to the effect that the program completed its task normally, e.g. “end of processing”, “program completed normally”, “all done”, or an equivalent. For example:
printf(“Program completed normally.”);
Never change the value of a for loop variable inside the loop.
Avoid the duplication of code. Every job, task, or formula should be implemented in one place.
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com