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="Jesper Nordenberg, post: 530442"] It's bad. I'll point out why below. Looks like an enum. Don't use int's, use a type safe enumeration pattern: [URL]http://members.tripod.com/rwald/java/articles/TypeSafeEnumeration.html[/URL] In this example there is no need for an enumeration though. Don't use protected fields. Use private fields and getters/setters (which can be protected). Subclasses can mess up these fields if you're not careful. Switch statements always have a bad smell. Almost all switch statements should be replaced with inheritance and polymorphism. Looks like either bMember and bList, or cMember and cList are used which means you have unused fields which wastes memory and makes the class confusing. To me it looks like bMember and bList should go into the B class, and cMember and cList should go into the C class. I don't see what bMember and cMember is used for though. Maybe they can be removed. Empty classes are always a bad smell ;-) /Jesper Nordenberg [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Java
Please comment on this class hierarchy design
Top