Using patterns for reducing complexity

Igor Budasov
WebDevOps
Published in
1 min readJun 18, 2018

There is a common opinion that OOP patterns reduce complexity of code and project in general.

To me it was sort of obvious, before I spoke to a frontend guy, who hates OOP and does some functional programming. He said that he hates all these abstractions and factories, because it’s too complex.

The thing here is: there are 2 types of complexity

  1. State complexity —it’s when your method has a lot of lines and does a lot of things one after another, and in unit-tests you have to mock all the dependencies in order to re-assemble needed state.
    OOP patterns help here, but increase structural complexity
  2. Structural complexity — it’s when you have to add a level of abstraction in order to get rid of state complexity. You introduce an interface, then the interface needs a factory, then you create worker classes. Yeah, on level of single class it’s simple, but look at whole structure — it’s far away from simplicity. But what’s good — you can learn patterns and know them.

Conclusion

Complexity doesn’t go away just because of you use OOP. It’s being transformed from one type to another, often more systematic and learn-able.

--

--

Igor Budasov
WebDevOps

A traveller. A drinker. A photographer. A blogger. An engineer.