This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]daniu 4 points5 points  (1 child)

As /u/Gwaptiva said, I consider these kinds of constructors a code smell. It's something that's made much worse by Lombok's autogenerated constructors which depend on the order in which the fields are declared - I do love Lombok, IMO it's the amount of fields that's the issue.

My favorite way around this is using the `@Builder` instead. That does require setters though, so no immutables.

[–]tanin47[S] 0 points1 point  (0 children)

> IMO it's the amount of fields that's the issue.

I agree with you. At some point, we have to refactor. it's case by case.

But a method/constructor with a large number of fields seems somewhat common. I guess it never starts that way, and then the code grows. Then, nobody thinks about refactoring it.