Generic base class wraps nested generic class to reduce type argument specification: Is there a name for this pattern?

前端 未结 3 1220
臣服心动
臣服心动 2021-01-15 19:41

Ok question title is far from being self-explanatory. I see myself doing this often:

From this answer:

public static class Equality
{
    pu         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-15 20:43

    I don't think you've followed any one pattern here.

    I would say that by replacing multiple "CreateComparer" methods with a single "Create" method, you have just simplified a Creation Method pattern. You could in a sense say it was a sort of a Factory pattern?! Or maybe a Builder pattern - that one is open to interpretation I guess?!

    By embedding "Impl" within "Equater" you have sort of followed the Command pattern - encapsulating method invocation so that your calling code doesn't know about how it's getting done.

    Anyway, sorry I can't be more helpful than that or give you a definite answer! Anyway, hope it helps!

提交回复
热议问题