Programming Guidelines:
One of the purposes of this course is to prepare you for a
programming job in the real world. With
that in mind, I expect very professional code from you.
Professional environments often have their own company
policies for capitalization and naming conventions, and this standardization
greatly contributes to code that is quickly understandable for multiple
programmers. While practices may vary, I
expect you to follow these guidelines for your code in this course:
Naming Conventions:
- While
Visual C# is case-sensitive, Visual Basic is not,
and conceivably your work could be applicable to both. Therefore use capital letters where
appropriate, but do not create two names which differ only by uppercase
and lowercase letters. (ie:
Dog and dog).
- Variable and method
names should start with a lowercase letter.
- According
to the CLC: Common
language Specification, no underscores or hyphens should be used in
your names. For multiple-word
names, use camelCase: myVariable.
- Method
names should start with a verb, so we are aware that they perform
actions. For instance, a method
name called displayText() is much more descriptive than the same method if
just called text().
- Class names start with an uppercase letter: MyClass. (this is also called PascalCase).
Formatting:
- Although
C# is not sensitive to white space, you should properly indent your
work. I do not care if you use tabs
or a certain number of spaces, but your indentation method should be
uniform and clearly visible.
- Do not
allow your lines to wrap; continue long commands on the next line.
- Do not
be afraid of white space. Using
blank lines appropriately in your code, like between function
declarations, only increases the readability.
Commenting:
- Comment
your code. Seriously. As a guideline, 10% of your lines should
be comments or contain comments.
- However,
your comments should be useful:
- “More
isn't always better. If you pour comments over your badly
written code like ketchup over a lousy steak, you will have created a mess
even more hard to decipher. [Likewise, no amount
of ketchup and/or steak sauce is going to make that steak any better. ]” - Kurt
Eiselt
- Especially,
document the purpose of every method above its definition.