accessor/mutator functions

Thomas Lotze thomas at thomas-lotze.de
Mon Feb 28 19:39:13 EST 2005


Dan Sommers wrote:

> I think I'd add a change_temperature_to method that accepts the target
> temperature and some sort of timing information, depending on how the rest
> of the program and/or thread is structured.

But then you put application logic into a library function. Doing this
consistently leads to a monster of a library that tries to account for all
possible applications. Where does this leave the KISS principle?

> In the case of simply reading the current temperature, and not knowing
> what's inside that device driver, I'd still lean away from exposing a
> current temperature attribute directly.  I think part of my thinking comes
> from my old Pascal days, when it made me cringe to think that "x:=b;"
> might actually execute a subroutine rather than just copy some memory
> around.

Then you also avoid lists, dicts and, ironically, methods. Accessing
methods means to access a callable attribute, after all, with all the
stuff going on behind the scenes on attribute access.

-- 
Thomas





More information about the Python-list mailing list