On Jan 31, 2008, at 5:17 pm, Eric Williams wrote:
>
> On Jan 31, 2008, at 1:39 PM, Lars Jensen wrote:
>
>>> True enough - but this seems like extra work to me. Why not just
>>> keep
>>> track of everything as you create it? That way you'll always know
>>> what's going on instead of having to repeatedly cycle through all
>>> the
>>> windows to find the one you want.
>>
>> "Keeping track of" is another way of saying "caching information
>> about". Caching is an optimization. Premature optimization is bad
>> because it increases complexity and therefore risk of bugs.
>> Therefore,
>> unless you have a need to keep track of something (e.g. for
>> performance reasons), it's generally better practice to ask the
>> system
>> for current information.
>>
>> Put another way: always ask the system, and if the system needs to
>> cache the info, it can. That way, the benefit of caching is spread
>> while the complexity remains contained.
>
> Yikes! So I shouldn't keep track of document windows when they are
> created? It's not as if a document window is going spontaneously
> materialize behind my application's back - document windows only come
> into existence when my app creates or opens a document. And when I go
> to shut down my application, I can cycle through each document object
> and tell it to close its window (instead of cycling through all the
> windows in memory, figuring out if they are document windows, and
> sending them a close command). This seems to me to be the very
> underpinnings of object orientation.
On the other hand... RB provides us with an event - CancelClose -
which tells you why a particular window is closing. If the appQuitting
flag is set, ask the user to save the document. To me, THIS "seems to
be the very underpinnings of object orientation." Make it the
responsibility of the OBJECT to determine whether or not an action
should take place, not the entire app.
But I digress... Introspection huh Charles? I'll need to do more
research about that.
GregO
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|