What's the point of DSLs / fluent interfaces

前端 未结 7 1124
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-01 04:11

I was recently watching a webcast about how to create a fluent DSL and I have to admit, I don\'t understand the reasons why one would use such an approach (at least for the give

7条回答
  •  遇见更好的自我
    2021-02-01 04:29

    Further to @sam-saffron's suggestion regarding the flexibility of a Fluent Interface when adding a new operation:

    If we needed to add a new operation, such as Pixalize(), then, in the 'method with multiple parameters' scenario, this would require a new parameter to be added to the method signature. This may then require a modification to every invocation of this method throughout the codebase in order to add a value for this new parameter (unless the language in use would allow an optional parameter).

    Hence, one possible benefit of a Fluent Interface is limiting the impact of future change.

提交回复
热议问题