concept accidental complexity in category dsl

appears as: ccidental complexities, accidental complexity, ccidental complexity
DSLs in Action

This is an excerpt from Manning's book DSLs in Action.

  • The DSL script must abstract the underlying implementation. This principle is an important part of good abstraction design, and it applies to DSLs as well. The DSL script cannot contain accidental complexities that deal with implementation details.
  • The domain vocabulary is explicit in the implementation and we don’t have much noise from accidental complexities polluting the essence of the domain model. (For more about accidental complexity, see appendix A.) Because this is the first of the domain models that we’ll carve out in this chapter, let’s look at some of the Scala features that make this model expressive yet concise.

    param returns a monad Option[String] . Option[] is a monad in Scala that you can use to abstract a computation that might not produce any result. queryTrade returns another monad, Option[Trade] , which has a type that’s different from Option[String]. We need to chain these computations such that if param returns a null value, queryTrade must not be invoked. We did this check explicitly in listing 6.24. Using monadic structures, the underlying implementation of the monad Option[] takes care of this plumbing so that your code remains clean and free of accidental complexity .