| Author |
Performance
|
maha devan
Ranch Hand
Joined: Mar 16, 2004
Posts: 50
|
|
Hi Anybody pls clarify my doubt I am creating an object and passing 8 parameters to the constructor.. Can i pass any number of parameters to a constructor..?? I want to know 1. Is it a bad design 2. Will it affect the performance of my program in any way.. Anybody pls clarify my doubts Thanks in Advance
|
 |
Mani Ram
Ranch Hand
Joined: Mar 11, 2002
Posts: 1140
|
|
MD: Can i pass any number of parameters to a constructor..?? Sure. MD: Will it affect the performance of my program in any way.. I don't think so. MD: Is it a bad design Might be. Might not be. Why can't you group the individual parameters with an object? For example, Replace with Where Name object will contain the firstName, lastName & the initial. And the Address object will contain the address details.
|
Mani
Quaerendo Invenietis
|
 |
Hanna Habashy
Ranch Hand
Joined: Aug 20, 2003
Posts: 532
|
|
hi: personally I think it is a bad design to pass 8 parametes to a constructor or a method. I think the max number should be 4, and less is better. But again, it is my own opinion.
|
SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26166
|
|
|
Martin Fowler agrees with what Hannah said in his classic refactoring book.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
Originally posted by Jeanne Boyarsky: Martin Fowler agrees with what Hannah said in his classic refactoring book.
See for example http://www.refactoring.com/catalog/introduceParameterObject.html
|
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
|
 |
 |
|
|
subject: Performance
|
|
|