3 ms·
Interesting that your two examples would be called: object-oriented ("top-down") and functional ("bottom-up"). After a lifetime of programming, I actually pref
by lioeters 9y ago
Interesting that your two examples would be called: object-oriented ("top-down") and functional ("bottom-up").
After a lifetime of programming, I actually prefer the latter approach: composing functions that are without side effects and independently testable.
I'm not sure if your examples reflect the top-down/bottom-up concepts in the original article, and certain don't agree that "a lot of jr developers" prefer the bottom-up approach, or that it looks "hacked on top of each other". Maybe it's just personal preference..
- yen223 9y agoYeah, I second the preference for the latter approach. It encourages more reusable components - you get to use `format_user_data` in situations which don't require data validation, for example. The one downside is the second style of code is a little uglier in languages without a good function composition operator, like Python. I enjoy writing stuff like user = data |> format_user_data |> validate_user_data in languages that support the pipeline operator.