DEV Community

Candace Eckels
Candace Eckels

Posted on

1

Inheritance and Modules

I've learned that the major difference between these to tools is the use case. Inheritance I will use if I need to instantiate a class and then the next class I use builds off that previous class(I want it to mimic a 'parent-child' relationship). Whereas modules I would use when I didn't need to instantiate and instance.

I have found that this is best used for calculations that are used across multiple classes. An example might be a total calculation. That can be used in multiple classes. Instead of writing out this total calculation for every class I need it in I can create a module that holds my method and then have my classes call on that one total method to find my totals.

If you wanna checkout my project click here!

Top comments (0)

Cloudinary image

Optimize, customize, deliver, manage and analyze your images.

Remove background in all your web images at the same time, use outpainting to expand images with matching content, remove objects via open-set object detection and fill, recolor, crop, resize... Discover these and hundreds more ways to manage your web images and videos on a scale.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay