Member functions for derived information in a class

后端 未结 6 1618
你的背包
你的背包 2021-01-22 13:39

While designing an interface for a class I normally get caught in two minds whether should I provide member functions which can be calculated / derived by using combinations of

6条回答
  •  不要未来只要你来
    2021-01-22 14:02

    I think this is perfectly valid if the method:

    • fits in the class responsibilities
    • is not too specific to a small part of the class clients (like at least 20%)

    This is especially true if the method contains complex logic/computation that would be more expensive to maintain in many places than only in the class.

提交回复
热议问题