How to name factory like methods?

后端 未结 11 1879
别跟我提以往
别跟我提以往 2021-01-29 19:41

I guess that most factory-like methods start with create. But why are they called \"create\"? Why not \"make\", \"produce\", \"build\", \"generate\" or something el

11条回答
  •  时光说笑
    2021-01-29 20:32

    I'd call it UriFactory.Create()

    Where,

    UriFactory is the name of the class type which is provides method(s) that create Uri instances.

    and Create() method is overloaded for as many as variations you have in your specs.

    public static class UriFactory
    {
        //Default Creator
        public static UriType Create() 
        {
        }
    
        //An overload for Create()
        public static UriType Create(someArgs) 
        {
        }
    }
    

提交回复
热议问题