4 ms·
OOP does not have a monopoly on abstraction and encapsulation. What OOP does, namely object-level encapsulation, is just a very extreme way of structuring code
by taffer 4y ago
OOP does not have a monopoly on abstraction and encapsulation. What OOP does, namely object-level encapsulation, is just a very extreme way of structuring code around mutable state. IMO the better alternative is to avoid mutable state as much as possible and keep data and code separate. Code structured as pure functions is easy to test and encapsulation can be done at the module level.
- optymizer 4y agoMy point is that improving the state of unit testing has little to do with OOP, and everything to do with the environment that the code runs in.
- kagakuninja 4y agoOOP does not require mutable state. OOP has its origins in imperative languages, and so in the past OOP often involved poor management of mutable state. I am a Scala programmer, and our code mixes OO and FP. Almost all of our classes are completely immutable. In the end, you will always need to encapsulate data and functions in some manner. The FP approach involves module systems, but as I understand it, objects in Scala actually provide a better module system than found in pure FP languages.