COMPOSITION AND INHERITANCE MODEL COMPARISON - Sergejevs, Aleksejs; Kodors, Sergejs (HUMAN. ENVIRONMENT. TECHNOLOGY. Proceedings of the Students International Scientific and Practical Conference, 2019)
The inheritance seems to be the natural and the default solution of structuring the logic of software nowadays. But is it always the best option? Considering the increasing need for programming and the speed at which the projects are made, it’s inevitable that the requirements of a project will be changing many times and a lot of fundamental building blocks in the software will have to be redeveloped. The problem with inheritance is that with a change in functionality it may become necessary to rewrite huge amounts of old code or even end up duplicating existing functionality which only makes things worse in a long run. An excellent solution that can be used to avoid essentially getting stuck in situations like these is composition. The goal of the study is to analyze the pros and cons of composition and inheritance and make a conclusion about their correct usage.