How to name factory like methods?

后端 未结 11 2019
别跟我提以往
别跟我提以往 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:34

    I like new. To me

    var foo = newFoo();
    

    reads better than

    var foo = createFoo();
    

    Translated to english we have foo is a new foo or foo is create foo. While I'm not a grammer expert I'm pretty sure the latter is grammatically incorrect.

提交回复
热议问题