Pop vs oop


I always felt OOP was far superior to POP. On the premise that JavaScript used POP because they never got far enough to implement true OOP. Ref Dart which is JS w/ OOP but hasn’t caught on. value types doesn’t have OOP inheritance. So they have to use POP. Functional programming uses POP. Multithreaded apps favour value types because they are easier to work with when designing multiprocessor apps. CPU’s are not getting faster anytime soon, so we have to use many processors to achieve speed gains. Enter POP. Swift makes POP easier to do with it’s extension system, which can be thought of as a sort of light version of code injection.

POP VS OOP

If you find your self having similar code in many places, your probably doing it wrong. consider using POP. Because with POP you can reuse the same code.

Drawbacks with pop:

ITs harder to understand the structure, what overrides. Ive developed a way of thinking about called “shallow deep” Basically. Shallow calls are calls that comes from class. And deep calls are calls that comes from a template method in a protocol. You can override calls coming from template methods, But at that point you can only call the same method across. calls form shallow on the other hand can also override and call a sort of “super” on the same method. The drawback is that you have to be peculiar when you design your method chains when compositing with protocols. As oppose to OOP where you can easily just call up and down the hierarchy with super and override. Ill explain with a diagram:

POP Pro’s

  • Easy to maintain
  • Zero duplicate code (Get your codacy/Codebeat GPA up)
  • Supports Multithreaded code
  • Makes your code more modular
  • Add new functionality to your code w/o affecting altering underlying code. Light code injection.
  • Less code per class

POP Con’s

  • Hard to get working
  • Hard to understand the architecture of your app. What calls what? what blocks?
  • Mixing OOP and POP things get complicated.

OOP Pro’s

  • Easy to get working
  • Easy to see where calls go and come from

OOP Con’s

  • Complexity grows
  • Hard to maintain
  • Duplicate code grows as your project grows
  • Impossible to maintain after a point.
  • More code per class