• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Constructors in abstract classes

 
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know you can have them in there, basically for all your subclasses to call super(); and set some parameters, but is it a common practice to use constructors in abstract classes, is it generally avoided, or does it just depend on the situation?
Since constructors instantiate an object to a certain state, I tend to avoid putting them in abstract classes, because it just doesn't make sense to stick them there, unless convenient. I don't think this is a conscious effort, but instead just goes with the way I visualize the program in "real world" concepts.
Pro's, con's, ideas?
Thanks!
Jason
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The decorator pattern is used to provide additional implementation through use of an abstract superclass constructor with a interface as a parameter.
 
Skool. Stay in. Smartness. Tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic