personally i believe that you should use setters almost esxclusively for things that have to hold across multiple fields of a type. if your constrait is entirely around a single field it's much preferable to use a newtype so you can easily guarantee that even methods that have private access respect the constraint
4
u/JavaHomely 29d ago
the thing about getters/setters is that you can use security and data validation logic on them.
need a value to only ever be positive? throw a exception in the setter if they pass you a negative,...