Even worse FooImpl abuse

At some point I’m guessing that the SheepImpl I’m looking at was an implementation of a Sheep interface, which extended the Animal interface. There’s also an AnimalImpl class. The Impl classes are generated by persistence layer stuff, so there’s some logic there.

(Why couldn’t we just have called it PersistedSheep, or GeneratedSheep, or HibernatingSheep? Would that have been too obvious, perhaps?)

There are other unrelated uses of Impl as implementations for interfaces – GrassImpl for the Grass interface, MangerServiceImpl for MangerService – you get the picture. It seemed reasonable to assume that the animals followed the same daft convention.

Assumptions are dangerous. Conventions are dangerous, especially when they are conventions in sheep’s clothing, so to speak. I should have read the code more carefully.

Sheep is now also a class with its own functionality, and is extended, not implemented, by SheepImpl. Sheep itself extends Animal (also a class) but not AnimalImpl. It’s taken me half an hour to work this out, and now my head hurts. Partly from unravelling spaghetti this late on a Friday, but mostly from doing this:

*Bangs head on table repeatedly*

Note: The actual code is in a retail application and has nothing to do with sheep. Thinking about things in terms of sheep, however, is helping me to be less stressed about this. One sheep. Receipt for one sheep. Special offer: two sheep for one! I would like four sheep, please. I’m sorry, Sir, we only have three sheep in stock, but I can order a fourth sheep for you.

Dreaming of electric sheep. Hmm.

This entry was posted in Uncategorized. Bookmark the permalink.

8 Responses to Even worse FooImpl abuse

  1. icklemichael says:

    My favourite useless naming convention is *Manager. Never ever provides you an incite at all as to what it does. Well, rarely, anyway.

  2. anonymous says:

    Are you so new to this business that you haven’t come across code written differently than you would do it? It’s extremely bad form to insult the work of others. It might very well be bad code, but it’s not very becoming to publicly berate it.

  3. sirenian says:

    Are you so new that you can’t tell the difference between “code written differently” and “code that is hard to work with”?

    I deliberately used a Sheep class rather than the original names so that the origin of the example would be obscured. It’s now merely an example of what’s going on, but unlike the others, an instance of this kind of code really exists. I don’t think it was the effort of any one person, or deliberate; more a creep of spaghettiness which has evolved over time. I believe that my code-mates here have thick enough skins that if they did feel a sense of responsibility they would either say, “Yeah, you’re right” or enter into debate with me over it.

    Unless you’re one of those people, I would leave it to them to take me to task for picking on their work. If you are responsible then come over and say Hi some time and we can have a constructive conversation on the merits of idealism vs. diplomacy.

  4. anonymous says:

    It’s just a bit silly to be so high-and-mighty all the time.

    Besides, why don’t you go and fix it instead of whinging to the world about other people’s work?

    I didn’t write the code. I’ve never called anything *Impl in my life.

  5. sirenian says:

    I Know you’re aware of my FooImpl bee-in-the-bonnet; this code is another example of why you shouldn’t use FooImpl, and not merely a whinge.

    I’d be very interested to read your blog, if you’d care to link it. I don’t think there’s anything wrong with mine, but it never hurts to see another style of work.

  6. anonymous says:

    I don’t have a blog. I’m sorry I was mean. It’s something about the *bangs head on table* sort of thing that gets my back up because it feels so incredibly condescending.

    Thing is, I totally agree with mostly everything you said. I was just bothered by the tone, and having a rough day.

    It’s kind of like one culture inflicting their ideas on another culture. Your ideas on OO aren’t really “right” or “wrong” and your post implies that you know better than the original silly oh-they-have-so-much-to-learn people. Your convention is just different than theirs. And it’s really not much more than convention. I’m talking about the Impl stuff by the way, not the weird class hierarchies you found.

  7. sirenian says:


    See, *Bangs head on table repeatedly* is as much about my assumption as it is about the bad code – the realisation that my way of thinking and someone else’s are so far at odds with each other that the language of whoever wrote this is completely unintelligble to me.

    The thing is, I reckon my way (and it isn’t just mine) uses really simple, plain, basic English instead of encoded ideas (which is what *Impl is), so anyone can read it, even people who aren’t developers. So yes, maybe it’s just convention – but one convention is more immediately accessible than the other. I hate things which stop people communicating. Every man-made problem in the world exists because people can’t or won’t talk honestly to one another.

    And I would have told you all that, and thanked you for giving me a “Hmm, maybe he’s got a point” moment in your first comment, except that… well, your tone could use a little work too.

    Thank you for your apology. I feel as though I ought to be apologising for something too, but I don’t think I’ve done anything outrageous enough to merit it (yet). Certainly I’m not sorry for my blog. 😛

    Please feel free to point out any potential outrages in the future; maybe a little more gently. I will, as always, take comments on board. And introduce yourself some time!

  8. anonymous says:

    The longer I have been in the business of sw development [1] the more I feel that naming is perhaps the most important issue in sw design at code level. It is also very much overlooked. Remember that you might write it in five minutes or use six months for it but it might be in production (for others to read and to modify) for years and years [2]. So I enjoy a lot when someone writes about naming. And provoking the auto-learned conventions that creep into naming is even better.

    *Impl and Abstract* are things I have often thought about but have not come to any good rules of thumb on how to get rid of them in my own programming efforts.

    Just keep on blamin’ us on bad namin!



    PS: No, I do not have a blog (yet?).

    [1] As pro I have now about 11 years of experience so I consider myself an apprentice although they want to give me these titles like chief this or senior that.

    [2] Slashdot: Oldest Supported Software?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s