I’ve been teaching the Game Programming class with Unity 3D for two weeks now. This is the first time we’ve used Unity in the class. It’s been interesting, and a challenge to my previous knowledge on the subject. In previous iterations of the course, we used Flash and Actionscript.
Something new I learned about recently is the comparison between inheritance and composition in object oriented programming. I hadn’t really encountered composition before, only the inheritance approach. So when diving into Unity, I didn’t really see OOP with inheritance and I wondered why that was the case. It turns out the Unity uses a composition approach.
Basically, instead of having a superclass and subclasses that all must conform to or override the superclass, each object is assembled out of components or capabilities.
This old JavaWorld article explained it nicely for me. https://www.javaworld.com/article/2076814/core-java/inheritance-versus-composition–which-one-should-you-choose-.html