What does it mean that "Object Oriented Programming imposes discipline on indirect transfer of control"?
Asked Answered
C

1

7

I have recently finished reading Clean Architecture book by Unckle Bob. There he wrote

Three paradigms. Three constraints. Structured Programming imposes discipline on direct transfer of control. Object Oriented Programming imposes discipline on indirect transfer of control. Functional programming imposes discipline upon assignment. Each of these paradigms took something away. None of them added any new capability. Each increased discipline and decreased capability.

  1. What does indirect transfer of control mean?
  2. How it is restricted in OOP?
Conspecific answered 27/6, 2022 at 12:8 Comment(1)
Uncle Bob talks about it here too softwareengineering.stackexchange.com/a/65175/309031Rayborn
S
7
  1. What does indirect transfer of control mean?

Pointers to functions.

  1. How it is restricted in OOP?

Polymorphism.

A more complete explanation can be found on the bottom of page 42.

The bottom line is that polymorphism is an application of pointers to functions. Programmers have been using pointers to functions to achieve polymorphic behavior since... the late 1940s.

The problem with explicitly using pointers to functions to create polymorphic behavior is that pointers to functions are dangerous. Such use is driven by a set of manual conventions. You have to remember to follow the convention...

OO languages eliminate these conventions and, therefore, these dangers. Using an OO language makes polymorphism trivial. That fact provides an enormous power... On this basis, we can conclude that OO imposes discipline on indirect transfer of control.

The discipline imposed in OO is that pointers to functions are accessed exclusively through polymorphism and never used explicitly.

Siler answered 27/6, 2022 at 19:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.