software-tools-books / js4ds

JavaScript for Data Science
https://third-bit.com/js4ds/
Other
185 stars 31 forks source link

Using OOP [class y extends x] to build on existing code: from example to real world application #56

Open MayaGans opened 5 years ago

MayaGans commented 5 years ago

The examples in the OOP chapter does a great job introducing the user but we should highlight how the original class doesn't have to be written by the user (Maybe I assumed this because the examples start from scratch?), and I think make sure it's in bold font how we don't need to fork and mess with original packages but can use OOP to extend them to do what we want

Example: I thought I needed to fork data-forge in order to create a new method myGroupBy within dataForge.DataFrame, not fully grasping that I could write

class MyDF extends dataForge.dataFrame {
    myGroupBy()....
}

I think if we include an example, aside, or even an exercise asking the reader to extend a data science related package to have a new/modified method it'll help to contextualize when they'll be using this.

gvwilson commented 4 years ago

Do you have an example in mind for this, or should we turn it into an exercise?