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.
posted 14 years ago
Answered this in Beginner Please do not cross post.
"JavaRanch, where the deer and the Certified play" - David O'Meara