There are apparently many examples of fields in logback classes that are not 
private to the class implementation.  For example, SyslogAppenderBase contains 
seven examples of mutable fields that are not private.  Best practice would 
suggest that unless there's a really good reason to break encapsulation by 
exposing such fields, they should be private.  In the case of 
SyslogAppenderBase there appears to be no reason for exposing most of these 
fields; apparently the "private" modifier was omitted as an oversight.  
Properly marking fields as private is a significant aid to project 
contributors, in that the scope of the field is explicit and limited.  
Moreover, it is much easier to contemplate making changes to a properly 
encapsulated class.

I propose that as a general practice, logback contributors should mark all 
mutable fields as private and expose properly documented accessor methods with 
appropriate access modifiers as a better alternative to allowing field state to 
directly accessed and possibly modified.

Comments or opposing opinions?

carl






Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

_______________________________________________
logback-dev mailing list
[email protected]
http://mailman.qos.ch/mailman/listinfo/logback-dev

Reply via email to