Below are a compilation of 20 software development best practices:
- Always use source control system even if the project has only one developer. By doing that, you don't lose some or whole code immediately, can share same source file by multiple person and can take the whole advantage of coding histories.
- Follow coding standards and check that standard with automized tools.
- Be consistent. If you do operations in a specific way, do that kind of operations in the same way (e.g. defining variable/method/class names, paranthesis usage etc.).
- More code does not mean better code. Keep it simple and reduce complexity.
- Don't use magic numbers and strings directly in the code. Use constants. This method provides more modularity and understandability.
- Don't use comment lines to delete code, just delete. Version controling system will help you if deleted code is required.
- Delete unused methods and classes. Version controling system will help you if deleted code is required.
- Catch specific exceptions instead of highest level class 'Exception'. This will provide understandability and more performance.
- Use understandable and long names for variables. Loop variable names can be i, j, k, index etc., local variable names must be longer than loop variables, parameter names must be longer than local variables and static variable names must be longer than parameters; proportional with scope size.
- Package related classes (that changed together and/or used together) together.
- Use understandable comments. Bad comment is worse than no comment.
- Use positive conditionals. Readability of positive conditionals are better than negative ones.
- Use dependency injection to manage too many singletons.
- Use exceptions only for catching exceptions, not for control flow. Think as required and perform control flow with control statements/conditionals.
- Don't use so many arguments with methods. Keep the number at most 8-10. If more is required, review your design.
- Don't use method alternatives with boolean flag variables (public void someMethod(bool flag)). Write more than one method for each flag condition.
- Method names must include "what is done by this method" information.
- Think twice before defining a method as static and be sure if you really need to. Static methods are harder to manage.
- Avoid using methods with reference parameters. Use multi attributed object parameters instead.
- Number of interface methods must be minimized to decrease coupling/dependency.