Is it unefficient in terms of computing performance when i use have/use methods with alot (more than hundred) parameters ?
I don’t mean efficient in terms of maintainability, but only in “raw” computing performance 🙂
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Theoretically, perhaps, since Java is pass-by-value, meaning that when a function is called, the JVM makes a copy of every parameter value and gives the copies to the function, so there may be some point at which the number of parameters has a non-negligible effect on execution time. But in practice, whenever possible, these copies are "shallow" copies, meaning that they’re more like references, so there is very little time spent actually making the copies. So you would probably need a lot more than 100 parameters to have any noticeable impact on performance time.
In any case, even considering the performance time of something like this sounds very much like premature optimization. It is almost certainly not the bottleneck for your program, so it’s not worth spending time on until you’re certain that it’s actually causing slowdown. If your program is unacceptably slow, investigate other possible sources of slowdown.
There is also, of course, as you mention, the issue of "maintainability." Why do you need hundreds of parameters for a single function? Are they complex parameters, such as ArrayLists of custom objects, or are they simple built-in data types? If the latter, why not consider packing them together into arrays, ArrayLists, and so on? Alternatively, why not break the function down into multiple functions? Modern computers are fast enough that for many (arguably most) purposes, programmer time is more valuable than processor time, so your first concern, when coding, should usually be whether what you’re writing is understandable and well-written, not whether it’s fast.