https://kotlinlang.org logo
#random
Title
# random
d

dalexander

03/29/2019, 2:04 PM
Does anyone know of a name for this anti-pattern? I think of it as the “diamond call” anti-pattern but I don’t know if it has an official name. Basically the pattern is you have some kind of control statement that calls the same function with different parameters, then the called function does different behavior based on the parameters. Usually it appears in more complicated contexts than this example. The solution is to just call different functions rather than having to branch again in the called function.
m

marstran

03/29/2019, 2:07 PM
A breach of the single responsibility principle?
But that would mean more than just that specific pattern though.
d

dalexander

03/29/2019, 2:09 PM
Yeah, it’s definitely at least that. I most frequently have seen it around event busses or observables where there’s some
BaseEvent
that’s been handled poorly.
r

r4zzz4k

03/29/2019, 3:02 PM
I'd say this antipattern is called "event bus" 🧌
3
3 Views