News for hackers. Stuff that matters.
Re:The Wrong Abstraction (2016) by mrfredward on Sunday July 05, 2020 @12:27PM (#23739846)
The business codebase I'm working on now was written by OOP crazy people who thought inheritance was the solution to every line of duplicated code. When they hit roadblocks, they filled the base class with things like if(this.GetType() == typeof(DerivedClass1)){...

I would do anything to have the duplication instead.

Re:The Wrong Abstraction (2016) by fauigerzigerk on Sunday July 05, 2020 @12:38PM (#23739940)
If you're truly OOP crazy you will always find ways to avoid resorting to branching on types or even avoid branching altogether (just on the language level of course). "There's a design pattern for that" :-)
Re:The Wrong Abstraction (2016) by BurningFrog on Sunday July 05, 2020 @12:33PM (#23739893)
Once you ask what the class is you're no longer even "OOP crazy".

You've just capitulated to the complexity and do whatever it takes.

I don't want to sound (too) condescending. I know how easy the best intentions can lead a project there. This job is hard.

Re:The Wrong Abstraction (2016) by pierrebai on Sunday July 05, 2020 @12:51PM (#23740047)
Checking for the type is the exact opposite of OO.

The correct OO would be to think about what the check represent, maybe abstract it in a base interface with pure abstract methods and derive from that interface.

What you describe is what people without understanding of OO do when they come from a language without OO.

Re:The Wrong Abstraction (2016) by raverbashing on Sunday July 05, 2020 @12:30PM (#23739872)
Very relatable. And they even have the guts to call this code "SOLID"
Re:The Wrong Abstraction (2016) by isbvhodnvemrwvn on Sunday July 05, 2020 @06:01PM (#23742462)
Then the very same people learn that inheritance bad, composition good, and they'll create abstractions with no meaning on their own, which call 10 vague other abstractions (but hey, no inheritance!). Figuring out what happens there is even worse than with inheritance. Some people grow out of it, fortunately (mostly after having to deal with shit like that once or twice).
Re:The Wrong Abstraction (2016) by mannykannot on Tuesday July 07, 2020 @11:06AM (#23760000)
> ...they'll create abstractions with no meaning on their own...

As if that doesn't happen with inheritance!

The dark pattern is using inheritance as an alternatve way of implementing composition. Anyone who thinks that "inheritance bad, composition good" is the proper response to this is probably as confused about the issue as those making the mistake in the first place.

To be clear, you are clearly not making that claim yourself, but you are invoking it to make a straw man argument.

Re:The Wrong Abstraction (2016) by goatlover on Sunday July 05, 2020 @05:55PM (#23742421)
> they filled the base class with things like if(this.GetType() == typeof(DerivedClass1)){

That defeats the purpose of polymorphism.