-
Notifications
You must be signed in to change notification settings - Fork 10
CodingStyle
When working on a large project, especially when the code is shared by many people, it is important to conform to a unified and consistent coding style.
In this course, we require that you conform to the coding conventions suggested by Sun. All the code that you submit must conform to this coding style.
IF YOU SUBMIT CODE THST DO NOT FOLLOW THE GUIDELINES, YOUR ASSIGNMENT WILL NOT BE GRADED AND WILL RECEIVE A 0 GRADE
Note that some of the code we present in class, in the recitation session (tirgul) or in the assignment descriptions, do not follow these conventions. This is because our primary concern for this code is to be short, concise, and to fit on a small space. However, whenever we distribute files, they will follow the conventions.
In order to verify that your code follows the coding style, you can use the checkstyle software, with the configuration we provide.
You can learn more about the checkstyle project here.
We will run checktyle on all the code you submit. If the output of checkstyle indicate any deviation from the coding convention, you will get a 0 grade. Please make sure to fix such errors BEFORE submitting the code.
Download the files:
The first file is the checkstyle software, the second is the configuration file we provide, specifying the coding convention we require.
You can have a look at the content of biuoop.xml if you are interested.
Running checkstyle:
> java -jar checkstyle-5.7-all.jar -c biuoop.xml JavaFile1.java JavaFile2.java ...The ... at the end indicate that you can add any number of java files. You can also specify many files using wildcards:
> java -jar checkstyle-5.7-all.jar -c biuoop.xml path/to/code/*.javaThis small exercise will help you make sure you get checkstyle to work:
- Download
checkstyle-5.7-all.jarandbiuoop.xmlfrom above. - Download the following code file FailingCheckstyleCode.java
Run the following command
java -jar checkstyle-5.7-all.jar -c biuoop.xml FailingCheckstyleCode.javaYou should see many checkstyle errors.
Fix the code so that checkstyle does not produce any more errors.