When packaging up a collection of settings, how do I know whether to use a CustomBinding, extend the Binding class, or extend one of the standard binding classes?

In most cases this should be easily decidable by asking at most two questions. The first question is used to decide between creating a custom binding instance and creating a new class for your binding.

  • Is your binding generally reusable such that you'd expect it to be dropped into other applications with few changes?

If your binding is not generally reusable or you don't care to make it so, then use a custom binding. Otherwise, create a binding class by extending Binding or by extending one of the standard bindings. The second question is used to decide between those two alternatives when creating a new class for your binding.

  • Can your binding be expressed as a simple derivative of one of the existing standard bindings?

If you're changing some of the default settings of the standard binding, then your binding is probably a derivative. If you’re changing or exposing some of the settings of binding elements that the standard binding doesn't normally expose, then your binding is probably a derivative. If you're adding a layered channel that doesn't have any protocol impact, such as logging, then your binding is probably a derivative. If you're adding or removing layered or transport channels that do have an impact on the protocol, then your binding is probably not a derivative.

A derivative of one of the standard bindings should be made by subclassing the standard binding class. A new binding is made by subclassing the base Binding class.

Next time: Resolving Conflicts in Serialization