Today i would like to convey some of standards which most of it companies follows. Method signature which is not suppose to get changed when ever each parameter of a method is removed or added. If so we have to change all the code which uses this method. So its better to pass HashMap instead of passing each and every parameter.
Example:
public void addUser(int empid,String passcode,String addressStandardization of Method Signature,int mobileNumber)
Consider addUser method is used to process user data. In future if we want to add some parameter to addUser method we need to change all the code which uses the method addUser
so it is better to send HashMap instead of sending all data seperately
HashMap hm = new HashMap();
hm.put("empid","id");
hm.put("passcode","***");
hm.put("address","____");
hm.put("mobileNumber","000000000");
public void addUser(HashMap data)
{
int id = Integer.parseInt(data.get("empid"));
}
Now if user want to add a new parameter he can easily add by
hm.add("sex","M");
Now the method signature remains same. It wont get changed each time when dev add or remove parameter. This is a good practice to code. If we go by this way then there is no need to change all the code which uses the method addUser. The method signature remains constant.