We're updating the issue view to help you get more done. 

Provide a ComposedObject base class for the Mixin-based composition pattern

Description

Add a ComposedObject base class for the Mixin-based composition pattern.

The class acts as a convenience base class for domain objects in the mixin-based composition pattern. It provides a This property that allows access to the composed interface, and a NewObject<TComposite> factory method that acts as a factory method for subclasses.

When a class inherits members provided by mixins, those additional members are only available by casting the class instance to the respective interfaces introduced by the mixins. This can be cumbersome, so the concept of complete interfaces was added. A complete interface combines public members of the mixed class with members introduced by mixins. The target class members are added to the complete interface either by having the complete interface extend an interface also implemented by the target class, or by simply redeclaring the members of the target class on the complete interface. The mixin members are added to the complete interface by having the complete interface extend the interfaces introduced by the mixins.

While complete interfaces provide easy access to the members added by mixins, they still require one cast (from the target class instance to the complete interface). To remove the need for this cast, classes implementing mixin-based composition can use the ComposedObject base class. When a class derives from ComposedObject<TComposedInterface>, it defines a complete interface for itself and all the mixins it composes via the UsesAttribute. That complete interface is called the composed interface.

The ComposedObject base class associates the composed interface with the derived class and provides a This property allowing access to all the members provided by the class and the composed mixins.

Status

Assignee

Fabian Schmied

Reporter

Labels

Time tracking

2h

Components

Fix versions

Affects versions

1.13.92

Priority

Normal