Announcement or simple method call (Command Pattern)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Announcement or simple method call (Command Pattern)

Oleg Richards
Hello Guys!

I want to use command pattern in my application and use announcements framework to invoke the same command in the same component from different places. Now it was done using simple method call. How do u think: Should i refactor my application to "command pattern"?

I'm afraid of one thing: For example one my component will subscribe to special command. When this component will be visible this is perfect. But what will be done if this component call another one, so it will be not visible, but not destroyed because it will be standing in stack of backtrace. Is it a danger? I dont want him to receive this message, when it is not active. And i also don't want to unsubscribe from event in every call procedure..

What do you think?

Cheers, Oleg
Reply | Threaded
Open this post in threaded view
|

RE: Announcement or simple method call (Command Pattern)

Sebastian Sastre-2
Hi Oleg,

        I think it depends on who wants to communicate to whom and the
coupling level you want/need. I'll evade the use of announcements where
loose coupling is not needed. But in the other hand the bigger the component
reuse the bigger the need of loose coupling. Remember that loose coupling is
needed when a children wants to communicate something about it's state to
potential parents or any subscriber without understanding anything about
them. If situation is simpler than that, and you can achieve the same
feature with a simple message send, so do it. You don't need/want to
complicate things just for fun.

        About components that should be disabled, I think you can use a
request (SURequest) to update the state of that component in the server
side. That way, when the command is called it can announce or not depending
on that state which your application (other components for instance) can
silently update it's state using this request.

        cheers,

Sebastian Sastre
 

> -----Mensaje original-----
> De: [hidden email]
> [mailto:[hidden email]] En nombre
> de Oleg Richards
> Enviado el: Lunes, 14 de Enero de 2008 06:16
> Para: [hidden email]
> Asunto: [Seaside] Announcement or simple method call (Command Pattern)
>
>
> Hello Guys!
>
> I want to use command pattern in my application and use
> announcements framework to invoke the same command in the
> same component from different places. Now it was done using
> simple method call. How do u think: Should i refactor my
> application to "command pattern"?
>
> I'm afraid of one thing: For example one my component will
> subscribe to special command. When this component will be
> visible this is perfect. But what will be done if this
> component call another one, so it will be not visible, but
> not destroyed because it will be standing in stack of
> backtrace. Is it a danger? I dont want him to receive this
> message, when it is not active. And i also don't want to
> unsubscribe from event in every call procedure..
>
> What do you think?
>
> Cheers, Oleg
> --
> View this message in context:
> http://www.nabble.com/Announcement-or-simple-method-call-%28Co
mmand-Pattern%29-tp14796959p14796959.html
> Sent from the Squeak - Seaside mailing list archive at Nabble.com.
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Announcement or simple method call (Command Pattern)

stephane ducasse

On Jan 14, 2008, at 5:03 PM, Sebastian Sastre wrote:

> Hi Oleg,
>
> I think it depends on who wants to communicate to whom and the
> coupling level you want/need. I'll evade the use of announcements  
> where
> loose coupling is not needed. But in the other hand the bigger the  
> component
> reuse the bigger the need of loose coupling. Remember that loose  
> coupling is
> needed when a children wants to communicate something about it's  
> state to
> potential parents or any subscriber without understanding anything  
> about
> them. If situation is simpler than that, and you can achieve the same
> feature with a simple message send, so do it. You don't need/want to
> complicate things just for fun.

Yes
Thanks for sharing that with us.
We need to record such practices and advices.

>
>
> About components that should be disabled, I think you can use a
> request (SURequest) to update the state of that component in the  
> server
> side. That way, when the command is called it can announce or not  
> depending
> on that state which your application (other components for instance)  
> can
> silently update it's state using this request.
>
> cheers,
>
> Sebastian Sastre
>
>
>> -----Mensaje original-----
>> De: [hidden email]
>> [mailto:[hidden email]] En nombre
>> de Oleg Richards
>> Enviado el: Lunes, 14 de Enero de 2008 06:16
>> Para: [hidden email]
>> Asunto: [Seaside] Announcement or simple method call (Command  
>> Pattern)
>>
>>
>> Hello Guys!
>>
>> I want to use command pattern in my application and use
>> announcements framework to invoke the same command in the
>> same component from different places. Now it was done using
>> simple method call. How do u think: Should i refactor my
>> application to "command pattern"?
>>
>> I'm afraid of one thing: For example one my component will
>> subscribe to special command. When this component will be
>> visible this is perfect. But what will be done if this
>> component call another one, so it will be not visible, but
>> not destroyed because it will be standing in stack of
>> backtrace. Is it a danger? I dont want him to receive this
>> message, when it is not active. And i also don't want to
>> unsubscribe from event in every call procedure..
>>
>> What do you think?
>>
>> Cheers, Oleg
>> --
>> View this message in context:
>> http://www.nabble.com/Announcement-or-simple-method-call-%28Co
> mmand-Pattern%29-tp14796959p14796959.html
>> Sent from the Squeak - Seaside mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: Announcement or simple method call (Command Pattern)

Oleg Richards
In reply to this post by Sebastian Sastre-2
Thank you, Sebastian!

Now i understand that i can just stay with simple message sending. As for menu: I can make some actions with replacing components and make other through blocks of code from components, who will do work for menu items.