Aren't Information Expert & Tell Don't Ask at odds with Single Responsibility Principle?

前端 未结 6 1534
没有蜡笔的小新
没有蜡笔的小新 2020-12-25 12:36

Information-Expert, Tell-Don\'t-Ask, and SRP are often mentioned together as best practices. But I think they are at odds. Here is what I\'m talki

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-25 13:14

    You can talk about "Tell Don't Ask" when you ask for object's state in order to tell object to do something.

    In your first example TransferObjectFactory.createFrom just a converter. It doesn't tell Customer object to do something after inspecting it's state.

    I think first example is correct.

提交回复
热议问题