2017-11-05
Summary of Clean Architecture Part II
blogentry, bookreview, programming, book
blogentry, bookreview, programming, book
After reading Clean Architecture, I've had a trouble understanding differences of each programming paradigm;
Let me share a summary of Clean Architecture Part II, Starting with the Bricks: Programming Paradigms.
Firstly, what is,
It is a programming discipline, used to decide which form of programming structure (SP, OOP, FP) to use.
Each paradigm places a constraint on a programmer.
NOTE: "Paradigm" is pronounced as par-uh-dahym NOT as par-uh-dig-uhms.
A direct transfer of control Example: goto statement is discouraged or removed. Instead of using a goto statement for an unconstrainted control flow, programmers are forced to use (now familiar) constructs such as if/else, for/while loops.
An indirect transfer of control Example: Function pointers are eliminated. OOP provides a plug-in architecture with a use of polymorphism. Polymorphism also enables a programmer to change the code dependencies with Dependency Inversion Principle.
A variable assignment Example: Cannot assign a new value to a variable.
SP causes noodlers (preventing spaghetti codes) to become an endangers species How? By discouraging the use of goto and encouraging functional decomposition and use of data structures.
Complete control over code dependencies and flows. How? By using dependency inversion with the use of polymorphism.
All race/deadlock conditions, and concurrent update problems. How? Problems mentioned above are caused by variable mutation. FP prevents variable assignment, thus those problems can't occur.
Initially, I thought about when to use each paradigm. When you consider a software architecture as a whole, it makes more sense to use each one appropriately.
So as an example, write low-level methods with SP principles, and separate immutable components (written with FP) from mutable components to mitigate resource contention and control flows with OOP.