Board index » delphi » Owner vs Sender

Owner vs Sender

I have just taken over maintenance of an application which uses Owner as
a parameter in places where I am used to seeing Sender. Are there any
advantages or disadvantages to using one or the other?

 

Re:Owner vs Sender


In article <34EA8337.51A3D...@2xtreme.net>, Peter Grossinger

Quote
<pet...@2xtreme.net> writes:
>I have just taken over maintenance of an application which uses Owner as
>a parameter in places where I am used to seeing Sender. Are there any
>advantages or disadvantages to using one or the other?

Like apples or curry, it depends on what you are using them for, and what you
know about them. There are no generic rules for using Owner or Sender except
what is needed, and where they are used. Without examples I cannot give advice.

Is the usage different from what you are "used to seeing" because the previous
programmer was careless or crafty, or because your experience is slight.

Alan Lloyd
alangll...@aol.com

Re:Owner vs Sender


In article <34EA8337.51A3D...@2xtreme.net>, Peter Grossinger
<pet...@2xtreme.net> writes

Quote
>I have just taken over maintenance of an application which uses Owner as
>a parameter in places where I am used to seeing Sender. Are there any
>advantages or disadvantages to using one or the other?

It's not really a case of advantage or disadvantage. By convention,
"Owner" refers to the component that owns the component in question
(like a form "owns" an edit box), and "Sender" refers to the
component that generates an event (an edit box is the sender
when it's OnChange event fires).

I must confess, I don't think I've ever seen anyone use "Owner"
as a regular function parameter, since any component already
knows what its owner is (Self.Owner), and you can easily find out
the "owner" of a "sender" with Sender.Owner.
--
Jeremy Collins

Re:Owner vs Sender


Quote
In article <NgaaQJAtxI70E...@jcollins.demon.co.uk> Jeremy Collins <j...@jcollins.demon.co.uk> writes:
>>I have just taken over maintenance of an application which uses Owner as
>>a parameter in places where I am used to seeing Sender. Are there any
>>advantages or disadvantages to using one or the other?

>It's not really a case of advantage or disadvantage. By convention,
>"Owner" refers to the component that owns the component in question
>(like a form "owns" an edit box), and "Sender" refers to the
>component that generates an event (an edit box is the sender
>when it's OnChange event fires).
>I must confess, I don't think I've ever seen anyone use "Owner"
>as a regular function parameter, since any component already
>knows what its owner is (Self.Owner), and you can easily find out
>the "owner" of a "sender" with Sender.Owner.

I believe that the "Owner" is supposed to be the object, if any, that will be
responsible for deleting this object when it (the owner) is deleted.  
Components have logic in their default destructor which iterates through this
list and frees owned objects.  But components don't have to have an owner.

"Sender" is used with event-handlers to inform generic event-handling routines
which control is receiving the event.  For example you can link 100 buttons on
a form to the same onClick routine, and use the Sender to distinguish which
button was pushed.

Other Threads