Skip to main content
6 events
when toggle format what by license comment
Mar 14, 2012 at 1:39 comment added Adam Lear If you have a constructor with 10 arguments, perhaps it's time to think about encapsulating those arguments into a class (or classes) of their own and/or taking a critical look at your class design.
Feb 29, 2012 at 4:49 comment added Mike Baranczak @Ricket: Because it increases the risk of putting the arguments in the wrong order. If you're using setters, or the builder pattern, that's pretty unlikely.
Feb 29, 2012 at 2:25 comment added Ricket Why wouldn't you want a constructor with 10 arguments? At what point do you draw the line? I think a constructor with 10 arguments is a small price to pay for the benefits of immutability. Plus, either you have one line with 10 things separated by commas (optionally spread into several lines or even 10 lines, if it looks better), or you have 10 lines anyway as you set up each property individually...
Feb 28, 2012 at 17:47 comment added 9000 As it was said decades ago exactly for this case, "If you have a procedure with ten parameters, you probably missed some."
Feb 28, 2012 at 17:01 comment added kevin cline Is a constructor with ten arguments worse than the NullPointerException that occurs when property7 was not set? Is the builder pattern more complex than the code to check for uninitialized properties in each method? Better to check once when the object is constructed.
Feb 28, 2012 at 16:37 history answered Mike Baranczak CC BY-SA 3.0