Style Guidelines
The following are style guidelines that you are required to follow in this course.
1. Commenting
Programs should be properly commented, which implies:
- Every class and method should be commented in a Javadoc compatible format (see Javadoc).
- Any hard-to-understand section in your code should be commented for clarity.
- BaliCompiler.java should have in a comment block at the head of the file the names and Net-ID's
of the students.
2. Capitalization
- Classes should be capitalized.
- Variables and methods should not be capitalized.
3. Project Specific Style
- Parsing should be split among multiple functions for good recursion.
- Easy to extend (functions can be easily reused to add new parts of the grammar).
- Classes should be distributed among multiple files. This means that there should be only one out, public
class per file (does not apply to inner or private classes).
- Enums should be used when applicable.
- There are not too many classes; i.e., there is not a class for every syntatical element (parentheses,
braces, etc...).
- The AST tree should not be too deep. There only really needs to be nodes for grammar elements that
produce code when compiling to SaM.
- It is a good idea to combine similar classes. For instance, addition and subtraction can be grouped into a
single
ArithmeticOperator
class with individual case statements, instead of having a different
class for each operator.