Typing system vs. Java

Courageous jkraska1 at san.rr.com
Sat Aug 4 12:55:46 EDT 2001


>> Various different rules which have crept up over the years such as
>> "don't use global variables," and "practice strong encapsulation,"
>> and so forth are all only distractions and are useless to the degree
>> that in any particular context they don't satisfy Sir Occam's relentless
>> blade.
>
>Except that they often promote ease of testing, modification and
>refactoring.  That is what gives them value.

Sure. There's a bit of give and take on this, however. Take, for example,
the oft maligned public variable:

While in context there is a good argument to be made for separating
interface from implementation -- and this is especially appropriate if
you are producing an API -- sometimes the public attribute is itself
the interface. If you changed the name of your attribute, you would be
changing the name of your setters and getters, and you'd be flying
through all of your files with sed substitutions in any case. I do this
all the time, myself, to maintain consistency.

Note that I'm not arguing against interface and implementation separation;
I am simplying pointing out that the rule "always have getters and setters"
isn't necessarily correct all of the time. IMO, this is particularly true in
situations where you have a package of objects which are mutually
manipulatory, but don't otherwise expose a public API.

C//




More information about the Python-list mailing list