Hello Readers,
In this post, I would like to focus on the coding standards to be followed when you are coding in Java.
Think of a situation wherein you have come up with a very optimized solution to a problem but you didn't follow the coding standards,your solution won't sell. It is regarded unworthy. So,in this section we are going to know the importance of Coding Conventions in Java.
Why to follow coding conventions in Java ?
- The straight forward answer is to make your code more Readable and Maintainable.
- Any programmer from any corner of the world will be able to understand your code. If you didn't follow the coding standards, even you cant understand your code after few days.Hence, it is very important to follow the coding standards.
- Each and every time you code something in Java.
- The first statement of a program has to be a package where in Java program reside.
- Class names have to be a noun and they have to be started with a capital letter and followed by lowercase letters.If it consists of two words, the second word first letter has to be capitalized. It is called as CamelCasing. Eg: Employee, Student, MainClass,etc.
- Interface name has to be an adjective and the rest is same as a Class.
- Method name has to be a verb and first letter starts with a lowercase letter and follows Camel-casing.
- Variable names have to be a noun with first letter has to be a lowercase letter and it follows Camel-casing.
- CONSTANTS have to be in uppercase only. They have to be declared as public static final.
- Java Beans should have private variables and should have getters ans setters methods to access them.
Good Code:
No comments:
Post a Comment