Application development best practices for newbies



In this article, I am going to share my experience when you just begin working on a new application. Sometimes this will not be suited for your taste. But I would like to share these things which make your life easier in the entire lifecycle of the application. These are not the coding standards, just tips & best practices for maintainable applications.

Choose a pattern for comments

If you are working with a team, discuss and choose a pattern to put comments in the entire application. Otherwise, you might be able to see different kinds of meaningless comments. For example, use date, developer nickname, issue no, and the description in header comments. Do not put stories, just explain what it does.

/*
* 20211016 RJ 1827 add implementation method of get users
* 20211019 NS 1856 refactoring getUsers() method
*/

This will be very helpful in the future when you enhance existing features, refactor code, or debug the application. A new developer can easily understand the code.

Put header comments

Header comments are very useful in future enhancements. You know when the change is made, who did it, and what is the purpose.

Choose a pattern and rules for naming

Have you ever experienced this, wasting time for naming a classmethod, or variable? In general, it takes too much time to think of a name. If the team has a pattern and simple rules for naming, it will be very easy. Otherwise, some developers may use long names, meaningless names, short names…etc. It makes our code less readable. It would be much better if we can define the min length, max length, case(camel case or snake case), and a pattern for classes, methods, and variables. Please look at the below examples. You need to choose the best one suited you.

getEmployeePersonalDetails()
getEmpPerDetls()
empPersnlDtls()
get_emp_per_detls()

Always use meaningful words.

Use meaningful words everywhere. It improves the readability of the code. New developers will be able to adapt and digest the code very easily.

Maintain documents

This is another very important thing. I have engaged in several legacy applications in different companies. Most of them don’t have any documents to configure the application.

Nobody knows how to set up the application, what are certificates are being used, what are the needful libraries, configuration changes, server configurations…etc. Sometimes it will take a few days to build & run the application. So I think documentation is very important.

Design and development

Another thing, most of the agile teams are working like, just assign the issue and the developer begins to develop without design. Sometimes at the end of the spring, the developer’s imagination may not be as expected by the BA. Then it drags into another sprint. You may select your own pattern and flow. I personally prefer few steps.

  1. Create issue
  2. Assign issue
  3. Create a design
  4. Approve the design
  5. Develop
  6. Assign to review

Maintain git branches

It is horrible to see some people use only the master branch and commit directly to the master branch. Don’t do that, maintain several branches and commit as a flow. For example,

This is not the git workflow, don’t misunderstand. First, create a feature branch from the master. Once developments are completed, commit and merge with the dev branch and QA branch. In some companies, it creates branches for each issue. Some of them use branch per developer. Some companies use few common branches. No matter which method you are using but it should not be committed directly to the master branch.

Write readable & meaningful codes

Personally, I am using simple methods and logic if it is possible. If you are making very simple things more complex, it will affect the readability of the application and sometimes the performance will be reduced.

Another thing is, always write codes in a positive manner with improved readability. You may wonder, I have seen if statements like below.

if(null != user.getName()){
}

This is completely fine but looks so negative and lacks readability. Don’t write code like this. Make it as a flow, then everyone can understand what is happening here.

Always try to put single-line comments if needed. When you write a code line, recheck them as thinking you are a newbie. If you cannot understand or catch the logic quickly, just put a comment.

Avoid writing long methods

This happens mostly in legacy applications. Some methods are very long, you will have to scroll again and again to read them. Just think what happens if you going to debug it? I can understand the pain because I know how much it hurts. Do not do this. Always try to write simple methods using a few lines of code.

Above I mentioned very basic best practices which can be used to make your application meaningful and maintainable. Happy coding!

Application development best practices for newbies Application development best practices for newbies Reviewed by Ravi Yasas on 3:26 AM Rating: 5

No comments:

Powered by Blogger.