Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Java
Please comment on this class hierarchy design
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="xarax, post: 530431"] /snip/ In addition to the other comments, you should also be wary of any occurance of a switch(){} block that is used to vary the processing depending on the type of an object. Such type-dependent processing should be delegated to the child class, usually through abstract methods in the parent class. However, some purists are strongly averse to calling abstract methods within a constructor, transfering control to the uninitialized child class. With careful design and implementation, it's not all that bad, and certainly more object-oriented than using switch blocks. Having said all of that, I do have some package-private classes that are very similar to what you posted (no switch block) that are programmatically generated. The use of type codes to enumerate the various subclasses is a safety check to be sure that I *do not* add more subclasses. The set of subclasses is fixed; the type codes are an easy way to verify that subclasses are not added incompatibly. (Remember these classes are programmatically generated, rather than handwritten.) /xarax [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Java
Please comment on this class hierarchy design
Top