Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

lets see what do you guys think?

 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't believe my eyes that I am seeing a constructor with around 50 parameters. My take is, this is ridiculous. your thoughts?
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The worrying thing is not so much that the constructor has 50 parameters (after all, a constructors with a parameter for each data member is a fairly common practice), but that presumably the class in question has 50 data members.

The only time I've seen this sort of thing in a reasonably well-designed system is as part of an object/relational mapping layer. Those 50 parameters match up with the 50 columns of a database table.

If this an internal model class, it sounds distinctly strange. Can you tell us more about what it is used for?
 
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Frank Carver:


The only time I've seen this sort of thing in a reasonably well-designed system is as part of an object/relational mapping layer. Those 50 parameters match up with the 50 columns of a database table.



In the same vein, it is not good data design to have about 50 columns in a database table. More than likely the data model is not normalized properly.
 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Normalization is often one of the first things thrown out in order to improve performance...

Without knowing more, it is hard to tell if having so many items in the constructor is good or bad. Can some of the arguments be grouped together into objects themselves, and then use a composition relationship?
 
Udayan Patel
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Kishore Dandu:


In the same vein, it is not good data design to have about 50 columns in a database table. More than likely the data model is not normalized properly.



well actually no, it is a "highly" (well read overly here) normalized database. However data related to "one transaction" IS huge as it has multiple subsets of data. but instead of these subtype object of their own they are being stored as primitives in master transaction. I still don't buy into constructor with too many parameters.
 
Udayan Patel
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Don Morgan:
Can some of the arguments be grouped together into objects themselves, and then use a composition relationship?



Exactly, Thats what I was thinking.
reply
    Bookmark Topic Watch Topic
  • New Topic