What is Subclass and composition. What is diffrence. Why use or not use
These terms are found within object-oriented programming paradigms, or OOP. If you talk about subclasses, you’re probably referring to inheritance than subclasses which is essentially having the same functionality as the superclass and additional functionalities.
Composition(or better termed as object composition), however, doesn’t inherit the features of another class, but instead acts as an independent component from other classes.
You should try looking up the following keywords:
OOP, object-oriented, paradigm, object composition, aggregation, subclass, superclass
By principles, it should be composition over inheritance. Just remember that OOP is not the only paradigm and one should know that you can use more than one paradigm at once!