[Biojava-l] Access to variables

David Huen smh1008 at cam.ac.uk
Tue May 9 13:12:24 UTC 2006


On May 9 2006, Nathan S. Haigh wrote:

>Apologies if this comes through more than once - I forgot to send in plain
>text without attachments!
>
>In case you don't know - I'm new to Java
.
>
>I'm working out an interface/class structure for part of an app I want to
>convert from Perl to Java and I have a question about the best way to
>provide access to variables to the client programmer:
>
>Is it best to have variables you want the client programmer to access just
>made public or is it best to provide access to them via a get/set method?
>> From my limited reading of "Thinking in Java" I would think it best to 
>> hide
>the implementation from the user and provide methods to access these
>variables e.g. setThreshold and getThreshold modify the private variable
>threshold - is that correct or am I way off the mark!?
>
Breaking object encapsulation is generally a bad thing in OO programming 
so, yes, avoid it when you can. We try to make it difficult to do so in 
BioJava anyway :-).

Regards,
David




More information about the Biojava-l mailing list