Thanks Jethro, really nice article, something for me to study in coming weeks for sure.
I was an OOPer for over 15 years. The main take away was the SRP principal (Single Responsibility Principal). Once I learned to assess my brand new block of code and follow that rule, it lead me to the next step. If there were any mixed responsibilities, I immediately refactored them to a new method. This ultimately allowed me to see the end result which was lots of small re-usable (functions) methods. OOP leads us to functional programming styles when we take the SRP principal seriously.
Its not really that different than the DRY principal. Reason? Because if you never repeat your code, you are forced to the functional and composition styles.
I agree. But I've also heard the assertion "functions in the small, objects in the large", so I wanted to emphasize that it is possible and potentially a good idea to use functions all the way up
Yes no problem with that idea. As we build reusable parts, we have no choice but to use Composition as our style, which you referred to in this article. Nice...
If we use only composed functions it is no different than using composed classes. OOPers have been composing classes for 30 years now. The concepts are identical. So really. It's a matter of containment and how to implement.
AFAIK, Typescript compiles everything down to functions anyway.
Depending on your compile target, yeah. However, those constructor functions create objects and v8 turns objects into hidden classes so everything is everything :)
Thanks Jethro, really nice article, something for me to study in coming weeks for sure.
I was an OOPer for over 15 years. The main take away was the SRP principal (Single Responsibility Principal). Once I learned to assess my brand new block of code and follow that rule, it lead me to the next step. If there were any mixed responsibilities, I immediately refactored them to a new method. This ultimately allowed me to see the end result which was lots of small re-usable (functions) methods. OOP leads us to functional programming styles when we take the SRP principal seriously.
Its not really that different than the DRY principal. Reason? Because if you never repeat your code, you are forced to the functional and composition styles.
I agree. But I've also heard the assertion "functions in the small, objects in the large", so I wanted to emphasize that it is possible and potentially a good idea to use functions all the way up
Yes no problem with that idea. As we build reusable parts, we have no choice but to use Composition as our style, which you referred to in this article. Nice...
If we use only composed functions it is no different than using composed classes. OOPers have been composing classes for 30 years now. The concepts are identical. So really. It's a matter of containment and how to implement.
AFAIK, Typescript compiles everything down to functions anyway.
Depending on your compile target, yeah. However, those constructor functions create objects and v8 turns objects into hidden classes so everything is everything :)
blog.sessionstack.com/how-javascri...
See also wiki.c2.com/?ClosuresAndObjectsAre...
I wasn't referring to V8 internals, just comparing the new Javascript Class to Functions described here:
developer.mozilla.org/en-US/docs/W...