• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

difference between accessing class constructor and method in the class

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi every one.
I have one query in terms of performance.

calling the class constructor is expensive and calling the method in the class is expensinsive in terms of performance.

which one is better to pass the parameter.

i.e overloaded class constructor or class method.

waiting for reply.

regards
narasimha rao konjeti.
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For an object, you may only call the constructor once, and make your design-decision on this fact.

To compare performance, make a prototyp and test.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Generally speaking, it is memory allocation that takes up the most time in object construction.
Of all the reasons to decide between a no-args constructor and one with arguments, performance is so far down the list that it is invisible.
Your architecture should strive for maximum clarity and maintainability and not chase after supposed microscopic performance improvements.
Bill
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic