Java constructor with large arguments or Java bean getter/setter approach

后端 未结 18 2158
清歌不尽
清歌不尽 2020-12-12 21:29

I can\'t decide which approach is better for creating objects with a large number of fields (10+) (all mandatory) the constructor approach of the getter/setter. Constructor

18条回答
  •  轮回少年
    2020-12-12 22:09

    Are there variations of the class that might take fewer arguments, or is there just one and it has ten properties?

    Is the object meant to be immutable?

    Personally, I don't see anything wrong with large constructors, especially if there's only one constructor, and all the properties are final too.

提交回复
热议问题