24

What's the point of abstraction layers if you're riddling all the code with

if (AbstractionLayer.SomeType instanceof ImplemantationLayer.SomeTypeIml1) {
// do stuff
} else if (AbstractionLayer.SomeType instanceof ImplemantationLayer.SomeTypeIml2) {
// do stuff
} else if (AbstractionLayer.SomeType instanceof ImplemantationLayer.SomeTypeIml3) {
// do stuff
} else if (AbstractionLayer.SomeType instanceof ImplemantationLayer.SomeTypeIml4) {
// do stuff
}

???

Seriously.. Guys. Am I missing some point here?

Comments
  • 5
    Nah, that's a massive code smell. Usually I see it when people start abstracting their code ok, but then aren't sure how to achieve something later on while keeping the same abstraction - so they bodge it (or just don't know better), and you end up with this mess.
  • 2
    This is called monomorphism 😂
  • 2
    What the hell? Didn't they hear about the virtual keyword yet?
  • 0
  • 1
    This is what interfaces are for...
  • 0
    @Brolls yeah, interfaces are there. And yet the implementstion ir queried via instanceof
  • 0
    @7Raiden I think he meant virtual classes in c++. Sort of interfaces in java world [? Correct me if I'm wrong]
  • 0
    @netikras Well yeah, I was kidding 😂! I was imagining the reaction when one actually told this guy that it should use virtual 😂
  • 1
    You should check Enterprise fizzbuzz
Add Comment