Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #15488
| From | markspace <-@.> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: object oriented design question in context of Java program |
| Date | 2012-06-21 07:20 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <jrvaja$ksj$1@dont-email.me> (permalink) |
| References | <c561248d-7f5c-4925-a23e-640de59a4541@t20g2000yqn.googlegroups.com> |
On 6/21/2012 4:42 AM, J W wrote: > distinct class hierarchies that consist of an abstract base class and > a set of six subclasses - one for each of the six work stages. The > most clear example of such a hiearchy is one to capture the stage- > specific scheduling rules. However, there are other similar but > separate hierarchies as well. > > My question is whether the repetition of the work stage-based > inheritance hierarchies constitutes a poor design or "a design smell", > and whether there are alternatives or design patterns that can be > applied to improve it. The general idea seems fine. However, the "other similar but separate" classes does bother me a bit. It depends on how repetitious and how confusing (or clear) the result is. Your basic plan is to avoid any switch-case statements or if-else cascades selecting different hierarchies, or different members of the same hierarchy. You want to use a single method call, like stage.workPlan( item ); rather than a bunch of if-else statements selecting different work plans based on the type of item. If you can avoid switch-case or if-else, and the break-down of responsibilities is clear and loosely coupled, I don't think you'll have much code smell. Complexity is OK as long as its required: complex problems require complex code to satisfy their requirements. Mostly code smell depends on unnecessary complexity, so depending on how rough the code is will affect the amount of code smell. By itself, a few class hierarchies aren't code smell. The devil of course could be in the details. We'd have to see the whole code base, or a large part of it, to determine any further code smell. Short examples won't cut it because short examples will be short, and therefore won't smell. I think you should ask your co-workers for advice. Or heed their subtle hints; sometimes unspoken advice is the more important.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
object oriented design question in context of Java program J W <jjw101023@gmail.com> - 2012-06-21 04:42 -0700
Re: object oriented design question in context of Java program markspace <-@.> - 2012-06-21 07:20 -0700
Re: object oriented design question in context of Java program markspace <-@.> - 2012-06-21 08:06 -0700
Re: object oriented design question in context of Java program Lew <lewbloch@gmail.com> - 2012-06-21 11:33 -0700
csiph-web