There is a function that I call once in a day :
new SubmitLogs().mail(IP, date_time_UTC, date_time_IST , pageVisited , userCountry , userRegion , city , userAgent);
The function arguments keep on growing. Initially it was like :
new SubmitLogs().mail(IP, date_time_UTC, userAgent);
and now it has 5 more arguments. It is expected to contain more arguments in a week.Now I do not like this.Maintaining functions with so many arguments doesn’t seem to be a good thing to me. Is there any work around for this ? I will never want to send some 50 arguments to a function if it keeps growing. What the call does is email the details in the argument with a short message and a short subject.
You have two options really
Try and group some of the parameters together into an object. This will encapsulate similar things together. For example you could put userRegion, userCountry and city together into a Location object
Alternatively the Builder pattern is good. Josh Bloch’s Effective Java has a good chapter on it.