3 ms·
The problem I found with OOP, is that it requires you to leave huge swaths of your code open and accessible, while you continue to develop and build out your co
by blackrock 7y ago
The problem I found with OOP, is that it requires you to leave huge swaths of your code open and accessible, while you continue to develop and build out your code. This requires a larger cognitive load to understand, internalize, and remember the mechanics of your code and all its relevant business logic.
In C++ and Java, you have these member variables, that act as global variables within the Object. Any member variable can be accessed at any time, either read or written to, by internal functions that are allowed to modify it.
This appears to work ok, while you write out your toy code for your CS 101 class, but it doesn’t seem to scale too well when developing real-world production code.
What I find better about Functional Style development, is that my functions are much smaller, and all inputs to the function, are validated, and its outputs fall within a narrow band that is acceptable. And by forcing the validation of all inputs, this tends to stop defects during development, very quickly, and very visibly.
The unit testing of pure functions becomes simpler, and it allows you to systematically perform rigorous validation of your code.
The added benefit, is that once I build out my functions, then all that complexity, is hidden behind a one-liner function call. And I just pass data containers from one function to the next, until I get my final desired result.
This helps to minimize the footprint of the codebase, that I must remember and internalize.
And since most of the parts are just dumb components, now, I can focus on remembering the core parts of the business logic instead.
Nothing is absolutely perfect of course, but this is as close to a programming silver bullet as I can get.
- jdlyga 7y agoI've worked on projects with a more iterative pipe and filters approach, and it can lead to situations where it's difficult to maintain or test anything. The problem that frequently occurs is that there's a new configuration parameter, but it needs to pass through a dozen different levels to get to the place that it's used. That and structs on top of structs as parameters gets very complex fast.