4 ms·
I agree on the performance impact. Where I think parent is right (but this is in no way unique to Java) is that it's much better to hide a class' structure as m
by mercurial 12y ago
I agree on the performance impact. Where I think parent is right (but this is in no way unique to Java) is that it's much better to hide a class' structure as much as possible. In particular, it is important to avoid the traditional bean pattern, with an empty constructor and plenty of setters. It makes it impossible to reason about which fields are mandatory for the object, and makes it possible for the method foo(yourObject) to change the object behind your back to something which doesn't make sense. Passing all fields through the constructor and/or using a builder pattern is much preferable.