官术网_书友最值得收藏!

Advantages of the Static Factory Method

Here are some of the advantages of a Static Factory Method over constructors:

  • It provides a better name for the constructor, what it expects, and, sometimes, what it produces.
  • We usually don't expect exceptions from a constructor. Exceptions from a regular method, on the other hand, are totally valid.
  • Speaking of expectations, we expect the constructor to be fast. 

But those are more psychological advantages. There are also some technological advantages to this approach.

主站蜘蛛池模板: 周口市| 客服| 浮梁县| 广东省| 张家港市| 玛多县| 通辽市| 德阳市| 花莲县| 海伦市| 南充市| 贡嘎县| 大同市| 罗源县| 沅陵县| 北碚区| 南靖县| 宜阳县| 襄樊市| 高雄县| 芒康县| 横山县| 射洪县| 彭泽县| 昌图县| 女性| 开化县| 太仓市| 白山市| 宁乡县| 宁夏| 达孜县| 廊坊市| 宜君县| 青神县| 南宫市| 中方县| 额尔古纳市| 水富县| 霍城县| 恩平市|