[Tutor] two questions..

Sean 'Shaleh' Perry shalehperry@home.com
Wed, 14 Nov 2001 13:40:59 -0800 (PST)


On 14-Nov-2001 Israel Evans wrote:
> 
> Thanks,
> 
> In addition, how and where would one describe relations between things,
> inside the objects themselves or in a sort of wrapper?   I suppose the
> problems come when trying to realistically model real world things and their
> resulting mechanics, rather than trying to mimic their functionality.
> 

Hard and fast rules are often wrong.  That said, objects should rarely know
about what they talk to otherwise you create arbitrary dependencies that are
not needed.

The usual approach is for classes to define a standard method name to look for.
 For instance the python's HTMLParser class (import htmllib) takes a formatter
class as an argument.  As long as it supports a few method calls the HTML
parser does not care what it is the formatter is doing.  Formatters have been
written to dump output to files and stdout, display the parsed html as a GUI,
and other tasks.

The real world is a complex and odd place, computers are much nicer (-:  Being
able to think of objects as real things helps us programmers get the job done. 
However we must not become fooled -- it is an illusion we create.