Hi > Am 14.11.2014 um 08:21 schrieb Chetan Mehrotra <[email protected]>: > >> E.g. the AbstractTree has protected mutable fields (bad practice per se, if >> exported even worse) > If that is by design (required for MutableTree) would it still be bad. > What would be the issue?
Just because something is by design, does not make it good :-) And I don’t say all fields must be final (though there is good reasons to do so). But all fields should (I’d even say must) be private and only be accessible through getters. All non-private fields make it close to impossible to ever refactor these fields. Add to it having the containing classes be exported as API and you get implementation lock-in. Regards Felix > >> Or TreeConstants exposing an „internal“ constant (should be a final class >> not an interface, actually) > Can change it to class but I do not see much issue in using interface > as holder for constants. Allows me to save bit on redundant typing of > 'public static final'!. The constant is not that internal, just a name > of hidden field I honestly don’t think we should be dropping good common practice and design on the notion of less typing, right ? ;-) An interface is something you implement to expose a behaviour. An interface sporting constants is not defining behaviour. Therefore a „container“ for constants should not be an interface. Regards Felix
