I frequently use a pattern where I using method chaining to setup an object, similar to a Builder
or Prototype
pattern, but not creating new objects with each method call, instead modifying the original object.
Example:
new Menu().withItem("Eggs").withItem("Hash Browns").withStyle("Diner");
Just wondering if there is a name for this pattern and whether it is considered an anti-pattern, because although it can read more fluently, it can lead to long method chains.
menu.withStyle("")
without context. You need two APIs in such a case.