Sanitized Hands and Programming Too
Sanitation, We heard this word many times in the last few days. We are facing an issue of COVID-19 and It has become an epidemic. So, Lockdown is going on in many countries these days to control this epidemic. We see that in The Newspapers, TV ads, SMS and Emails everywhere we are being told about sanitation for precaution. Let’s learn together to sanitized the programming also at this time.
Hello Everyone, I am sharing the steps that make your coding presentation to the new level. Let’s start:
- Indentation/Reformat Code: Always remember about indenting when you write the code, It makes easier to understand for you as well as the third person. Some popular tools provide the shortcuts to make the file with proper indenting. Let’s understand with the below pictures:
Code Without Indenting

Code With Indenting

## Shortcuts Eclipse: CTRL + SHIFT + fAndroid Studio: CTRL + ALT + l
2. Use Constants: When you write some string or number that means hardcode, You have to make a final constant.
For example, this is the code for check the user is valid or not.
String checkValidUser(UserDTO userDTO){
String result = null;
if(userDTO.getName().equals("")){
result = "Name is required";
} else if(userDTO.getAge() == 0){
result = "Age is required";
}else if(userDTO.getPhone().equals("")){
result = "Phone is required";
}
return result;
}
Let’s write using the constant:
## New File Constantpublic static final String BLANK = "";
public static final String NAME = "Name";
public static final String AGE = "Age";
public static final String PHONE = "Phone";
public static final String REQUIRED_MESSAGE = "%s is required";
public static final Integer ZERO_NUMBER = 0;## FunctionString checkValidUser(UserDTO userDTO){
String result = null;
if(userDTO.getName().equals(Constant.BLANK)){
result = String.format(Constant.REQUIRED_MESSAGE, Constant.NAME);
} else if(userDTO.getAge() == Constant.ZERO_NUMBER){
result = String.format(Constant.REQUIRED_MESSAGE, Constant.AGE);
} else if(userDTO.getPhone().equals(Constant.BLANK)){
result = String.format(Constant.REQUIRED_MESSAGE, Constant.PHONE);
}
return result;
}
3. Optimized Imports: When we write the code then sometimes we use some library function, extend the class and implements the interface, etc. and remove it but we forget to remove the import statement that written on the top of the class. So we have to keep in mind to remove it if it’s not used. Many editors provide a shortcut way to identify and remove automatically from the project. let’s look the image below.

Here the eclipse shows the indication that the two import statement is not used. Eclipse shortcut to remove unused import is COMMAND + SHIFT + o
4. Reused the code: Usually developers who make a mistake that they rewrite their code which is a very wrong way. So always think first of all whether we can use this code anywhere else. The last thing is that don’t repeat the statements make a function and use it.
5. Commit Message: We used some platforms to maintain our project code. Here I am talking about git
. In general, when we complete our task then we have to review our code to the senior person after the approval we push our code to the server. but in this process, we have to write the commit message that is ignored by the developers.
Commit messages should be clear because it identifies your task. The things that we have to keep in mind is:
a. Always write with the title like (## New Features)
b. If you develop a new feature then write in a short way that how to use this feature.
c. Always write with the points.
d. In the last line write the name of the person who approved it.
For Example:
git commit -m 'New Features:
1. Payment Reminder Option.
Steps To Use: (Dashboard -> Receivables -> Pick any party -> Change voucher to Bill Wise -> Send Reminder button to appear in the bottom of the app)Bugs fixed:
1. Settings: Logout was not working in MI Device.
2. Sign Up: DOB data was coming invalid format.Performance Improvement:
1. Socket Connection: Improve the lacking while connecting the slow internet connection.Approved By: Arnish Gupta
'
That’s it. I hope this article will help you. If you like this article then wait for a second and clap for me.
Thank you for reading.