Clean Architecture – Chapter 3 | Paradigm Overview

As per author there are three paradigms in programming – 

  1. Structured Programming
  2. Object Oriented Programming
  3. Functional Programming

Lets’s go through each of them briefly as subsequent chapters go in detail on them.

Structured Programming

Structured programming imposes discipline on direct transfer of control

Robert Martin

This paradigm was discovered last, but was the first to be adopted. It was discovered by Dijsktra. It removes the use of unrestrained GOTO statements. Goto statements were used to transfer control to another part of code, and once that finished, there would be another go to statement to return back. This would create unnecessary overhead in programming. Also, adversely impacting readability of code. He replaced goto with if/then/else and do/while/until, or more specifically what we now call conditional statements and loops.

 

Object Oriented Programming

Object-oriented programming imposes discipline on indirect transfer of control

Robert Martin

This paradigm was second to be discovered but was adopted after structured programming. It was discovered by Johan Dahl and Kristen Nygaard. They moved the function call stack to heap, which allowed the reuse of local variables by multiple functions. (Each thread has its own stack but multiple threads share the heap memory) Now in modern programming we have constructors in a class to initialize objects and instance variables. These instance variables are accessible to all the methods in the class. Thereby decreasing unnecessary function calls to pass those instance variables. 

 

Functional Programming

Functional programming imposes discipline on assignment

Robert Martin

This paradigm was the first to be discovered but last to be adopted. It was discovered by Alonzo Church. This is based on lambda functions in mathematics. Lambda functions are based on the assumption that values of the symbols do not change (Immutability). And most of the functional programming languages have no assignment statement. They do allow changing the value but under strict conditions.

Summary

Most of the modern programming languages today follow all three paradigms in some way. For example, Java, primarily object-oriented language, not long ago from Java 8 implemented functional interfaces to allow for functional programming. Another great example is Javascript. We will see Structured programming paradigm in next post and learn how modern languages heavily use it.

Thanks for stopping by! Hope this gives you a perspective on software paradigms. Post comments to start a discussion. See you in the next post.