• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

When designing a class, how do I know ...

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When designing a class, how do I know the following?
(1)What fields do I need?
Are there any systematic (scientific, disciplined) ways to figure that out as opposed to the intuitive ways used by those experienced programmers?
(2)Constructors are usually for initializing the fields in a class, but I've seen constructors do far more complicated things than that, such as opening up a database, performing animation, etc. How do I know what the constructors are supposed to do when designing my class?
(3)What parameters do I need for a method? Do I decide on this first before coding the method? Or do I code the method first and then come back to fill in the method signature?
Are there any books that deal with these topics?
I have been bugged by these questions for a long time. I appreciate if you programming gurus can share with us juniors how you overcome these hurdles.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Answered this in Beginner Please do not cross post.
reply
    Bookmark Topic Watch Topic
  • New Topic