classes (was Re: Same again please for OOP)

Erno Kuusela erno-news at erno.iki.fi
Sun Dec 24 23:54:18 EST 2000


>>>>> "Alex" == Alex Martelli <aleaxit at yahoo.com> writes:

| "Roy Smith" <roy at panix.com> wrote in message
| news:roy-E5B925.13324224122000 at news.panix.com...
[...]
|| The mp3 class might return a URL for its location() method, and the
|| CD or Vinyl classes might return a string, "Third shelf from the
|| bottom,

| Looks like a typical case of state mismodeled as behavior.  Why
| should 'location' be a method -- what does it *DO*?!  It doesnt _do_
| anything; rather, it's an 'accessor' for a part of the object's
| state.

i don't understand what is wrong with this - i like making them all
methods, so i don't have to remember if it's an attribute or method
later. also overrinding __getattr__ later, if it turns out to be
needed, is tedious and ugly.

why does the user want/need to know if "location" is stored directly
as an attribute or if computation is needed to to reconstruct it
from some other information?

  -- erno





More information about the Python-list mailing list