Explain emulating inheritance by composition
What will be an ideal response?
Multiple implementation inheritance is a well-established concept. Many popular development platforms, however, do not support it. The reasons are usually not only technological, but also logical. Single and multiple inheritance, however, can be emulated through composition. In fact, many prefer composition to inheritance regardless of whether the technology supports inheritance or not.
The composition approach is also called black-box reuse since the internal details of a class are not exposed to subclasses. Reuse by composition is dynamic. How a service is performed is decided by the object at runtime, and by the object only, not by its parent or parents.
Reuse by composition must rely on abstract interfaces to be workable. An abstract interface hides the internal composition of a composite object and allows the object to change its behavior without adversely affecting its clients.
You might also like to view...
Carson Company purchased a commercial property insurance policy. Under one provision of the policy, Carson would pay all covered losses until the sum paid reached $50,000; then the insurer would cover all future losses. This provision is a(n):
(a) corridor deductible (b) percentage participation clause (c) coinsurance clause (d) aggregate deductible
________ is the rung of the customer loyalty ladder where the customer convinces others to purchase/join
A) Word of mouth/buzz B) Repeat purchase C) Satisfaction D) Evangelism E) Ownership