DEV Community

Muhammad Fauzan
Muhammad Fauzan

Posted on

Why you should avoid using abstraction and interface

Using abstraction lead us to write another higher-level of abstraction if it's not leads, then your abstraction is bad.

e.g

abstract class CrazyExample
{
    abstract protected function getValue();
    abstract protected function getOptions();
    abstract protected function getValueAndOptions(); //??
}
Enter fullscreen mode Exit fullscreen mode

what is the benefit of hiding the complexity of a system? is it just to waste your time, you would be find the way back to your complexity during development again.

Discussion (2)

Collapse
aleron75 profile image
Alessandro Ronchi

Using abstractions allows us to write decoupled code.

Decoupled code is easier to test, thus to refactor and, in the end, to get better over time and not the opposite.

But we have to get into it and experience the frustration of code that get worse over time until we decide to rewrite everything from scratch.

And if we don't change our approach, we don't have any chance that the next rewrite will be better.

I never get tired of recommending to watch this masterpiece: vimeo.com/78898380

Collapse
fzn0x profile image
Muhammad Fauzan Author • Edited on

Oh i see, the point is decoupled code (usually classes) right? I'm currently using modular and doing very fine with tests (without abstraction), so is this like the good OOP way for doing tests (is to create abstraction first)?