|
From: Thomas G. Marshall on 18 Aug 2007 20:47 Jerry Coffin said something like: > In article <1171216519.131931.144410(a)v33g2000cwv.googlegroups.com>, > howachen(a)gmail.com says... >> for example, a Person class, I need to create a person using, e.g. >> >> Person peter = new Person('Peter', '....) >> >> the object creation might involved over 30 parameters, the advantage >> is this call is atomic, rather than something like, e.g. >> >> Person peter = new Person(); >> peter.setName('Peter'); >> peter.setBirthPlace('.... >> ... >> >> Are there any platterns, suggestion or anti-plattern related to this >> problem? > > 30 parameters is almost certainly excessive -- I'd suggest some sub- > objects to encapsulate some of the coherent pieces. ....[rip]... Yep. My instincts here are two fold. 1. 30 parameters should be better identified into their abstracted relationships (like many have offered), *unless* the parameters are truly disparate in nature. 2. ...and if you find yourself with a need for 30 truly disparate parameters, then the overall design is almost certainly in question.
From: H. S. Lahman on 19 Aug 2007 11:19 Responding to Marshall... > Jerry Coffin said something like: > >>In article <1171216519.131931.144410(a)v33g2000cwv.googlegroups.com>, >>howachen(a)gmail.com says... >> >>>for example, a Person class, I need to create a person using, e.g. >>> >>>Person peter = new Person('Peter', '....) >>> >>>the object creation might involved over 30 parameters, the advantage >>>is this call is atomic, rather than something like, e.g. >>> >>>Person peter = new Person(); >>>peter.setName('Peter'); >>>peter.setBirthPlace('.... >>>... >>> >>>Are there any platterns, suggestion or anti-plattern related to this >>>problem? >> >>30 parameters is almost certainly excessive -- I'd suggest some sub- >>objects to encapsulate some of the coherent pieces. > > > ...[rip]... > > Yep. My instincts here are two fold. > > 1. 30 parameters should be better identified into their abstracted > relationships (like many have offered), *unless* the parameters are truly > disparate in nature. > > 2. ...and if you find yourself with a need for 30 truly disparate > parameters, then the overall design is almost certainly in question. When the thread originally appeared here, that was pretty much the consensus, as I recall. All too often such objects show up as Singletons to hold a bunch of global data. ************* There is nothing wrong with me that could not be cured by a capful of Drano. H. S. Lahman hsl(a)pathfindermda.com Pathfinder Solutions http://www.pathfindermda.com blog: http://pathfinderpeople.blogs.com/hslahman "Model-Based Translation: The Next Step in Agile Development". Email info(a)pathfindermda.com for your copy. Pathfinder is hiring: http://www.pathfindermda.com/about_us/careers_pos3.php. (888)OOA-PATH
|
Pages: 1 Prev: Design pattern - where publishing? Next: Design Pattern Question |