For further actions, you may consider blocking this person and/or reporting abuse
Read next
Breakthrough: AI System Combines Language Models and Reinforcement Learning for Better Problem-Solving
Mike Young -
Inside NVIDIA's Hopper GPU: New Architecture Delivers 3X Faster Processing and 40% Lower Data Movement Overhead
Mike Young -
Stop Killing your Largest Contentful Paint score with images!
Alex Patterson -
Email Validation Code in JavaScript: 7 Ready-to-Use Methods for Developers
Team mailfloss -
Top comments (3)
The thing about inheritance is that you have to be careful when you design the hierarchy of your classes. It might solve an immediate problem that you have but later down the road they can become an obstacle to implement a new feature. I've heard people say that you should only use inheritance when you are absolutely sure you only need a
Parent
andChild
class, that is a hierarchy with just one level.When you use composition techniques it should be easier to just add new code without worrying about old code.
Inheritance in a class based system, everything is inherited from child to parent. If you have one branch of classes you can't brach to another one, which is bad about inheritance. You can't make new connections to other hierarchies, so if you decide that one class should also inherent from another class from a different hierarchy than you'll have to make a new design will includes that other class in your classes hierarchy. This in flexibility gets annoying and difficult to mange on large systems maybe its okay if you writing small projects
Imagine a big stack of cubes and having to swap one out at the bottom of the pile. That's inheritance.
Now imagine all those cubes side by side and making a change to one of them.
It's probably an oversimplification; but unless very well structured inheritance sets you up for a fall...