Смешивание быстрого и небыстрого интерфейса в одном классе

JUnit имеет встроенную поддержку этого, с "ожидаемый" атрибут

5
задан peterchen 8 July 2009 в 18:17
поделиться

1 ответ

I've not done much work with fluent interfaces (although I've played around with DSLs in general), but it seems to me that while the class may lend itself to this approach, it's not particularly necessary in this case. Maybe I'm missing something, but it seems to me that you are not likely to be doing a bunch of actions on a single string with no reference to anything else, which is what you've ended up with here. In addition, you're transitioning to new objects in the middle of the chain, which seems again to violate the purpose of a fluent interface, particularly when you consider what happens in this chain:

Str String = OtherString.GetFirstToken().SplitFirstToken().Trim();

I think perhaps that this type of relatively low-level utility class is the wrong place to try out a fluent interface. Fluency seems to me much more important when your objects are subject to persistent, focused attention than when they are transient and ancillary to the core logic.

3
ответ дан 15 December 2019 в 06:32
поделиться
Другие вопросы по тегам:

Похожие вопросы: