Coding Style
Coding Style
These rules are not meant to be followed to the letter: they are provided to encourage developers to
establish and apply guidelines when writing code, especially in a team setting. The proposed rules
are commonly used standards. However, there is no absolute rule, and each person may choose to
use all or part of the suggested guidelines.
3. Modularization
◦ Break down the code into small, single-purpose functions or methods.
◦ Follow the Single Responsibility Principle (SRP), ensuring that each class or
method has one responsibility.
6. Version Control
◦ Use a version control system like Git to track changes in your code.
◦ Make frequent, small commits with clear messages that describe the change.
7. Documentation
◦ Keep your code well-documented, both inline and through external documentation.
◦ Update documentation whenever you change the functionality of a method or class.
fi
8. Testing
◦ Write unit tests to verify that individual pieces of code work as expected.
◦ Test edge cases and ensure that error-handling paths work properly.
◦ Regularly run tests to catch bugs early.
◦ Write Javadoc comments for classes and methods to explain their purpose and
usage. Use /** ... */ syntax.
◦ Add inline comments sparingly to clarify complex logic, but avoid obvious
comments.
◦ Avoid excessive comments; instead, write clear and self-explanatory code.
4. Error Handling
5. Use of « nal »
◦ Use the final keyword where applicable to mark variables, methods, or classes
that should not be modi ed.
◦ This helps in improving code safety and communicating intent to other developers.
fi
fi
fi
6. Avoid Magic Numbers
fi