× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Is there any performance concern if too many parameter in a constructor?

James Jensen
Feb 10, 2015
<blockquote> <p>performance is the only concern</p> </blockquote> <p>The issues with oversized parameter lists have practically nothing to do with performance--your performance will probably be as good or better than if you used setter methods to set up your object. Of course, as in all performance-related cases, the best advice is to try it, and benchmark it, and see if you can measure any difference. If this isn't a part of your code that you've identified as slowing things down, then performance <em>shouldn't</em> be a concern for you at all, much less your <em>only</em> concern.</p> <p>However, having any method or constructor with such a large list of parameters makes your code unmaintainable and error-prone, and you should be seeking other options purely for the sake of code maintainability.</p> <p>This tip was originally posted on <a href="http://stackoverflow.com/questions/23228920/Is%20there%20any%20performance%20concern%20if%20too%20many%20parameter%20in%20a%20constructor?/23229011">Stack Overflow</a>.</p>
comments powered by Disqus