Java 17 is the officially supported version of Java for this course. If you haven't already installed it, you can download the JDK from the Temurin download site.
There is no required development environment for this class. That said, I personally use Eclipse, so I'll be able to answer Eclipse-related questions more easily that questions related to other IDE's. The style section below includes instructions for configuring either Eclipse or IntelliJ IDEA to support the course style requirements.
If you need detailed instructions for installing Java and Eclipse, you can follow the CS 159 installation instructions from last semester. DON'T follow the instructions for configuring the style preferences, as CS 240 has a different set of requirements.
The most important role of a set of coding standards is consistency. No group of programmers will ever completely agree on the best way to format code. Should code blocks be indented with tabs? With spaces? How many spaces? Two? Four? Eight? Where should opening braces be placed? The fact is, none of these things really matter that much. What does matter is consistency. It is very inconvenient for a group of people to work together on a shared code base if they don't agree on some set of common standards.
Code submitted for this course must conform to the Google Java Style Guide . We are using these standards because they are well documented, widely used, and supported by development tools.
The Google style guide is mostly concerned with low-level formatting issues like indentation and line length. Keep in mind that it is possible to write very bad code that is properly formatted and will pass automated checks. See Section 3 below for some additional style requirements.
Gradescope will use Checkstyle to automatically check the formatting of your submitted code. It may be convenient for you to run Checkstyle locally before submitting. The Google style checks should be included with Checkstyle by default.
The Eclipse Checkstyle plugin can be installed by following the instructions on this page:https://checkstyle.org/eclipse-cs/#!/install
Once the plugin is installed, the Google style configuration can be selected by accessing "Window->Preferences->Checkstyle" and selecting "Google Checks".
The Eclipse auto formatter can be configured to follow the Google guidelines by accessing "Window->Preferences->Java->Code Style->Formatter" and importing the following file:
The IDEA formatting preferences can be configured to follow the Google guidelines by accessing "Settings->Editor->Code Style->Java" and importing the following file:
Selecting informative names is one of the most important steps in writing readable, maintainable, and correct code. Variable names should clearly describe what the variable is intended to contain.
All names should be descriptive and readable:
subTotal rather than
grade rather than
grd. Variable names
should balance clarity with brevity. The name
is better than
per is worse than either
(percentage? person? permitted?).
The point of comments is to clarify code that might otherwise be difficult for the reader to follow. Well organized Java code with informative variable names should require few comments inside of method bodies.
Every programming assignment must contain the following section which follows the class description or must cite any sources used (such as a TA). You should either include this statement in all files or minimally it may appear in the file containing your main method.
/* * This work complies with the JMU Honor Code. * References and Acknowledgments: I received no outside help with this * programming assignment. */
/* * This work complies with the JMU Honor Code. * References and Acknowledgments: TA Glenn helped me with the * foo method. */This acknowledgment is not necessary for lab assignments. Note the single star after the slash; this is not a Javadoc comment.
continue except in switch statements.
there is a documented reason for not doing so.