In order for you to be able to demonstrate your understanding of your code, you will need to comment your code. To get credit for your code, your code needs to follow the guidelines in the Programming Grading Rubric and your comments will need to include the following. These comments are basically the questions that I would ask you to explain in person.
- Variables
- When you create a variable, either the name or comment should explain what purpose it will play in your code.
- Variable names should be descriptive of their purpose. Math calculation and counter variables can be named x, y, and z or i, j, and k.
- Methods
- At the beginning of each method, explain these three things
- What is the general function of the method?
- What are the parameters passed into the method and what are they used for?
- What does the method return or do?
- All methods need these comments, including constructors, setters, getters, and toString methods generated by Eclipse.
- If a method is overloading or overriding another method make sure to explain that.
- Overloading is when you have multiple methods called the same thing but use different parameters. See Game Character Overloaded assignment.
- Overriding is when you have a child method called the same thing as a parent method. See Inheritance Intro assignment.
- At the beginning of each method, explain these three things
- Loops: every “for” and “while” loop
- What the loop is doing?
- What conditions are met to begin the loop?
- What conditions are met to end the loop?
- How is the counter variable incremented or when does the conditional variable change value?
- Algorithms
- Explain chunks of code that perform a certain function. For example:
- Battleship program: code that kept a ship from being place out-of-bounds.
- Sorting algorithms: code that swaps array variables.
- Sorting or searching algorithm,
- Explain how the algorithm works in general.
- Explain how your code implements the algorithm
- Explain chunks of code that perform a certain function. For example:
- Main Program
- Many of your main programs are fairly short and/or straightforward.
- Comment what each line of your main program is doing if it hasn’t already been commented from something above.
- Special terms
- Every time you use the terms “super” or “this”, explain what those terms are doing in that line of code.
- Explain any temporary (temp) or swap variables.