advanced re-motion mixins -- potential for confusion

As pointed out earlier on this page, for the fluent interface to work, we must build an intermediate representation of the mixin configuration called the builder. Do not confuse the builder for the mixin configuration. What you build with chained methods like

.ForClass<TargetClass1> ().AddMixin<MixinClass1> ().AddMixin<MixinClass2> ().AddMixinClass<MixinClass3> ()        
.ForClass<TargetClass2> ().AddMixin<MixinClass4> ().AddMixin<MixinClass5> ()                                       
... more and more ...

is NOT the actual mixin configuration, it is the builder, an intermediate representation. Each method like ForClass<>, AddMixin<> and SuppressMixin does NOT give you an actual configuration item, it gives you some object that represents which methods you have piled on top of each other so far.

It is the final BuildConfiguration () method at the end that returns the actual mixin configuration instance. If you forget that BuildConfiguration (), you will get an instance of the wrong type, resulting in type errors (at compile time).

What's more, the "Build" in BuildConfiguration has a meaning that is very different from that of methods like BuildFromActive () or BuildEmtpy ().

  • BuildConfiguration () is a method of an instance of the intermediate representation. It gives you the mixin configuration you have assembled one configuration item at a time.
  • BuildEmpty () is a static method of the MixinConfiguration class and gives you an (empty, virgin, uninitialized) instance of the intermediate representation, ready for method chaining (= the fluent interface).
  • Along similiar lines, BuildFromActive is a method like BuildEmpty (), only that it constructs an intermediate representation from the active configuration instead of an empty one.