Best Practices for Software Developers
I am writing this post based on my experience in software development industry. Usually I try to share my skills and learnings with others. I am going to list down some best practices from my software development career, so if you think they make some sense for you then try to adopt few.
Let me elaborate the Software Developers best practices in the form of bullets, so that these practices can easily be understood.
- Every developer must use Source Control System, even if one developer is working on the project. This thing will keep you safe from loosing that source files, and you can also share these source files with other persons as well. Examples of Source Control System are : Clearcase , Tortoise SVN, CVS, Git etc.
- Always check-in your code at the end of day, do not leave it to tomorrow.
- Every Developer must keep code more simple and free from complexities. Lines of code(LOC) is indirectly proportional to the better code.
- There should be 10 LOC per method(recommended).
- There should be maximum 30 methods per class(recommended).
- Try not to use numbers and strings directly in the code, Try to use constants or read from a property file, this will make your code more understandable.
- Try to avoid commenting lines of code but simply delete those LOC. If you need that code in future Source Control System will provide those lines of code in history.
- Try to make project clean by removing unused methods and classes. If you need it in future you will get through Source Control System.
- Try to Catch Specific Exceptions instead of High Level Class Exceptions. This makes code more understandable.
- FileNotFoundException
- NullPointerException
- SQLException
- Try to use naming convention and understandable long variable names.
- Try to package all related classes to maintain the code.
- Try to use informative comments that will make code more understandable. Bad comments are more worse than no comments.
- Make Practice to always use Positive Conditionals.Using Positive conditionals are better than Negative ones.
- Method Names Should be self explanatory that must show the functionality of Method.
- GeneratePdfFile()
- SendEmail()
- Readfile()
- If you are going to define a method as static, you need to think about it because static methods are not easy to manage.
- Refactor the code if recommended after code review.
- Try to make instance variables always private, and create getters and setters to access them.
- Try to Practice Programming to an interface and not to an implementation, This will make concepts and developing applications well.
- Try to understand and start practicing/using Design principles which are important for applications.
- Single Responsibility Principle
- Open-Closed Design Principle
- An Intelligent Software Developer always try to write JUnit Test Cases for the code.
- Try to Present your work to Manager, Even its small or big but your manager should be aware of that what you have done or doing.
- Try to use new tools and techniques that may help you in improving performance of your development activity. i-e: Debugging Tools, FTP Tools, IDEs etc.
- Test Software Changes after every change in the application. Because it is necessary to conform that new functionality haven't disturbed the old functionality of the application.
- Do not treat any change in the application is a small change, you need to test it as well to avoid suffering in future.
- Always try to treat Software Bugs as your enemies, If you find any bug, Start testing and removing bugs.
- If you are going to send your code to senior developer for code review, make sure that you have not done any of the given below points in the code.
- OOP Not used in the Code / Bad Coding.
- Haven't followed any programming standards.
- Haven't kept software performance in mind during development.
- Indentations and comments are not properly done.
- Code readability is very poor.
- Files opened in the code are not closed.
- Memory Allocation has not be released properly.
- Used too many global variables
- Used hard coding instead of reading from Properties File or database.
- Poor Exception Handling.
- Duplicate code / Repeated code.
- Too many LOC in a single method.
If i forgot to mention any important point, do remind me and add that point to my knowledge as well.Your comments are welcomed for this post.
Worth reading, thank you for sharing.
Its worth reading..
V Good artical sir..
Good effort Salman, a mature guidelines for new comers.
Worth reading.