commercetools

What difference between Dsl and Builder classes for mapping some Drafts?


I have such a question about mapping Draft through the DSL classes and Builder classes.

For example:

CustomerDraftDsl and CustomerDraftBuilder

What difference between this approaches except that Builder classes has method build()? Some of them works faster or what?


Solution

  • CustomerDraftDsl

    The outcome of both is to build a SphereRequest. CustomerDraftDsl is an immutable data structure, so if you use a either you get a new instance like a modified copy.

    CustomerDraftBuilder

    CustomerDraftBuilder is a classic mutable builder where the parameter methods return the same instance. So there are two variants to support different programming paradigms.