Method Overloading. Can you overuse it?

前端 未结 16 1421
有刺的猬
有刺的猬 2020-12-02 13:38

What\'s better practice when defining several methods that return the same shape of data with different filters? Explicit method names or overloaded methods?

For exa

16条回答
  •  时光说笑
    2020-12-02 13:47

    Another option is to use a Query object to build the "WHERE Clause". So you would have only one method like this:

    public List GetProducts(Query query)
    

    The Query object contains the condidition expressed in an Object Oriented way. The GetProducts obtain the query by "parsing" the Query object.

    http://martinfowler.com/eaaCatalog/queryObject.html

提交回复
热议问题