Hacker News new | past | comments | ask | show | jobs | submit login

Oh man, I've been fighting a similar battle this month. I have to deal with a codebase which has to talk to a handful of proprietary protocols, which don't have the best interoperability between implementations. However the all the protocols look fairly similar at a macro level (general concepts, data structure layout, etc). So somehow this mutated into a terrible inheritance tree 3-9 classes deep, with absurd placement of special cases 4 classes upstream, or special case handling for a specific device in each class all the way up the inheritance stack, and worse.

So I am trying to convince the cargo cult inheritance people that there are patterns like strategy and "library of useful functions" to handle a lot of the code better. But they keep sticking on cargo cult DRY. No matter how many times I explain to them that we need to organize with repeated code, because as the future happens, and new versions of "interoperable" code will diverge in their special case handling and whatnot, we still can't repeat ourselves.

/rant

So yeah... Cargo-cult DRY is just as bad for readability and maintainability as spaghetti and big balls of mud.




Sometimes I really wish there were a way to make violating the Liskov Substitution Principle throw a compiler error.


Learn Haskell.


/picks-up-rant-baton

Ha -- I've seen this too.

This is why I've started hating inheritance. I see people who think 3-9 class deeps inheritance trees are ok, and they then go out and design new 3-9 class deep taxonomies, and become very proud of their abstractions. Of course, most times a simple function (or lambda) will do just fine to patch over the inconsistencies. By patch I mean something like middle-ware.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: