Skip to content

Ubiquitous Language

ChrisEdwards edited this page Sep 8, 2010 · 1 revision

Build Result

The instance constructed by calling build() on a fluent builder

Builder

An object that is used to build an instance of another type

Fluent Builder

See Builder

Target Type

The type (class) of object a builder creates

Custom Builder

A builder whose interface is custom designed. This is usally to create a more fluent interface that does not require the use of lambdas. Great for creating DSLs. Opposite of Dynamic Builder

When to use

  • When you want full control over the fluent interface.
  • When you don't want to see lambdas in your fluent interface
  • When creating public DSLs that are user-facing
  • When you don't want the Target Type's properties and methods visible to the user of the fluent interface

Differences from Dynamic Builder

  • Can specify custom default values to use for each property
  • Must create a custom builder as a subclass FluentBuilder (FluentBuilder is an abstract type)
  • Must implement custom methods to set property values through the builder
  • No access to the standard For, Having, & With methods that exist in the Dynamic Builder
  • Can perform custom processing on the build result before returning it (Override AfterBuild() in the custom builder)

Dynamic Builder

Builder that uses Fluency's interface and lambdas to set the values of the build result. Opposite of Custom Builder

When to use

  • When you don't mind lambdas in your fluent interface
  • When the provided lambda accessors (For, With & Having) are sufficient for your needs
  • When creating internal DSLs that are not user-facing
  • When you don't mind the Target Type's properties and methods being visible to the user of the fluent interface

Differences from Custom Builder

  • Provides lamba accessors For, With, & Having to set property values on the builder.
  • Do not need to create a subclass to use. DynamicFluentBuilder is a able to be instantiated directly
  • Cannot perform custom processing on the build result before returning it.

List Builder

Builder that is included in Fluency that is specialized to build lists of objects Is implemented as FluentListBuilder where T is the type of item to include in the list. The build result is of type IList Anytime you have a property that is a list, you wil need to use a list builder to populate its values.

Alias

An alias refers to a builder that simply returns a specified instance. The builder is said to be an "alias for" that instance. Use builder.AliasFor( instance ) to set a builder as an alias. Warning: when a builder is set as an alias, any previous calls to configure the build result are ignored, and any subsequent calls to configure the build result should fail.