Re:Post-Architecture: Premature Abstraction Is the Root of A...
by cryptica on Friday July 19, 2024 @04:04AM
(#41003208)
My view on FP is that one of its main benefits in terms of avoiding bugs is that it forces you to turn all your 'movable state' into raw messages. The fact that it aims to abolish 'unmovable state' is just a quirk of it, not necessarily a benefit.
My main point in support of OOP is that OOP doesn't prevent you from making all your 'movable state' into raw messages. Properly encapsulated instance state is actually not dangerous nor unpredictable. What I like about OOP is that it offers some additional benefits in terms of high cohesion and loose coupling because co-locating logic with related state helps to write high cohesion, loosely coupled modules. It allows my messages and function/method signatures to be even leaner than FP allows.
If you want to catch a taxi to the airport, FP still demands that you bring a jerrycan of fuel to give to your taxi driver, the only restriction is that he cannot alter it (no mutations). This has some benefits if you then plan to re-use that same jerrycan of fuel for your airplane too... But is that how the world works?
My main point in support of OOP is that OOP doesn't prevent you from making all your 'movable state' into raw messages. Properly encapsulated instance state is actually not dangerous nor unpredictable. What I like about OOP is that it offers some additional benefits in terms of high cohesion and loose coupling because co-locating logic with related state helps to write high cohesion, loosely coupled modules. It allows my messages and function/method signatures to be even leaner than FP allows.
If you want to catch a taxi to the airport, FP still demands that you bring a jerrycan of fuel to give to your taxi driver, the only restriction is that he cannot alter it (no mutations). This has some benefits if you then plan to re-use that same jerrycan of fuel for your airplane too... But is that how the world works?