[Arp] Similar buttons in ARP: what's best practice?
Rich Rodecker
flashape at gmail.com
Mon Jan 8 09:06:57 PST 2007
i say hell yeah, just store the value in the ML. don't make it hard
for yourself.
On 1/8/07, nyls <info at nyls.nl> wrote:
>
>
>
>
> Hey Michiel,
>
>
>
> Yes the most MVC approach is setting state/data (from a user action) through
> the controller ... views just listen for model changes..
>
> http://java.sun.com/blueprints/patterns/MVC-detailed.html
>
>
>
> So you could use a command for that kind of action, I like that approach in
> cairngorm / flex .. See the src off the following example..
>
> http://everflash.com/cs/blogs/everflash_blog/flex/Exp_02_CairngormClock/Exp_02_CairngormClock.html
>
>
>
> BUT in real live this can be overkill, it is your choice when to implement
> design patterns and to what extent.
>
>
>
> I use a singleton StateManager which keeps track of state, I could 'for the
> better' let views dispatch events and then let the controller set the state,
> but I prefer to let views set state themselves.. I think arp-views are also
> a kind of controllers (for there child views , components on stage ) So
> sometimes (for easiness) I store state data in the view itself ..
>
>
>
> The MVC pattern can be implemented on a lot of different levels, for example
> the mm V2 components are almost 'little' MVC pattern based creatures..
>
>
>
> So what does the list think ..
>
>
>
> nyls
>
>
>
>
>
>
>
> ________________________________
>
>
> Van: arp-bounces at ariaware.com [mailto:arp-bounces at ariaware.com] Namens
> Michiel van der Ros
> Verzonden: Monday, January 08, 2007 5:04 PM
>
> Aan: General List for Ariaware RIA Platform users and developers
> Onderwerp: Re: [Arp] Similar buttons in ARP: what's best practice?
>
>
>
>
> I was going over this old thread from october and was discussing it today
> offlist with another member:
>
> Basically the topic comes down to this: what is the best way to implement
> MVC with ARP when storing simple variables from small classes, like values
> of buttons? I've been working on the project where the original question
> arose from and also talked to some colleagues who program in Java.
>
> Nyls, in your first reply (scroll down to see the thread) you suggested to
> change a value from the view by directly addressing a model through the
> ModelLocator. But isn't that a violation of the MVC principle? These kind of
> things should always pass through the controller, because the view should
> not change the model, right?
> I've been struggling with this myself, because it seems such overkill to
> have a class send an event for every value it needs from the model, and
> waiting for the response event. Or even worse, creating Commands for each of
> these possibilities which are called from the model. Makes me dream back to
> the "good" old days where I'd just drop this variable into _global ;-)
> Anyway, I'd like to hear your thoughts on this!
>
> Thanks,
> Michiel
>
>
>
>
>
> nyls wrote: LOL, very nice allegory :>
>
> So we could add to the allegory that the ironing man and the bell boy could
> all be listening to the courier arrive (model changes) and can act
> accordingly ..
>
>
>
>
>
>
>
>
>
>
>
> -----Oorspronkelijk bericht-----
> Van: arp-bounces at ariaware.com [mailto:arp-bounces at ariaware.com] Namens Paddy
> Keane
> Verzonden: Friday, October 06, 2006 3:22 PM
> Aan: General List for Ariaware RIA Platform users and developers
> Onderwerp: Re: [Arp] Similar buttons in ARP: what's best practice?
>
>
> Hi Michiel,
>
> U could send optional arguments through the Controller but the code
> purists
> would advise against it as it goes against the grain of the framework.
> Jesse Warden has an example here:
>
> http://www.jessewarden.com/archives/2005/08/arp_labs_upload.html
>
>
> I'd use the ModelLocator or your 3rd option.
>
> I like your allegory but I think it would be better to think:
>
> You're not going anywhere. You call the hotel and tell them you need
> your luggage picked up, the hotel then sends a courier to get it. The
> Courier doesn't need to know what's in the luggage (just that you packed
> it yourself) if fact if he/she really knew what was in it there's a good
> chance you'd never see it again. Once the hotel has the luggage it can
> then follow further instructions (like taking it to your room or taking
> your shirts out to be iron...)
>
> Paddy ;)
>
>
>
>
> ==========================
> Paddy Keane
> Flash Developer & Office Juicer
> World Archipelago
> Eden House
> 59 Fulham High Street
> London SW6 3JJ
> Tel: +44 (0)20 7471 8330
> Fax: +44 (0)20 7471 8331
> Web: http://www.worldarchipelago.com
> Map: http://www.worldarcstudio.com/map/
> Personal Site: http://www.darklump.co.uk
>
>
>
> -----Original Message-----
> From: arp-bounces at ariaware.com [mailto:arp-bounces at ariaware.com] On
> Behalf Of Michiel van der Ros
> Sent: 06 October 2006 13:30
> To: General List for Ariaware RIA Platform users and developers
> Subject: Re: [Arp] Similar buttons in ARP: what's best practice?
>
> Hi Nyls,
>
> Yep, my parentView is listening for the click events of course. The
> listener calls a function and dispatches the event the Controller is
> listening for.
> I understand your method. Looks like the same complexity level as my 3rd
>
> option.
> The usage of the ModelLocator in general is not completely clear to me,
> since it's not documented in the 2.02 Developer's Manual. (I'm using the
>
> latest source from SVN though, which contains it. Will look into that.)
>
> Hmm, it would seem so much cleaner to me to just add variables to the
> event object. Else it's like driving your empty car to your hotel, check
>
> in and then send someone back home to get your luggage. But maybe I just
>
> need to tweak my intuition a bit more :)
>
> Michiel
>
>
>
>
> nyls wrote:
>
>
> Hello,
>
> First of all I would let the parentView listen for the click event of the
> buttons. There you can store the buttonState in a model through the
> modellocator
> (ModelLocator.getInstance().addModel("state").setValue(but);)
>
>
> and then dispatch it from there ..
>
>
> Then the commands can get it through
> ModelLocator.getInstance().getModel("state").getValue();
>
> Is this of help ??
>
> Nyls
>
>
> -----Oorspronkelijk bericht-----
> Van: arp-bounces at ariaware.com [mailto:arp-bounces at ariaware.com] Namens
> Michiel van der Ros
> Verzonden: Friday, October 06, 2006 11:05 AM
> Aan: arp at ariaware.com; alumni at ariaware.com
> Onderwerp: [Arp] Similar buttons in ARP: what's best practice?
>
> Hi all,
>
> I'm working on my 3rd ARP-based application and ran into something
>
> where
>
>
> I can't figure out best practice. Eventhough I studied Pizza Service
>
> and
>
>
> Birthday Organizer by heart :)
>
> I got a bunch of similar buttons in my screen. (They are actually used
>
>
>
>
> to switch psysical led-lights on and off by communicating with a piece
>
>
>
>
> of middleware)
>
> So what I'd like to do is have one command or maybe a business
>
> delegate
>
>
> to communicate with the middleware. Now I can add listeners to the
> buttons, dispatch an event and couple it to a command in the
>
> controller.
>
>
> But I'd like to pass the name of the button to the command somehow. Or
>
>
>
>
> just any way to trigger the same command with a different variable for
>
>
>
>
> each button.
> I considered the following:
>
> 1) Having different commands for each button. That would be redundant
> and ugly, so not an option for me.
> 2) What would seem a nice way to me is to add a variable to the
> dispatched event. No problem, but this value gets lost in the
> controller... (right?)
> 3) An option that might be best practice could be to store the id of
>
> the
>
>
> button in the view, then let the command call the view reference and
>
> ask
>
>
> for a valueobject, which contains the name of this button. That just
> seems so much more complicated to me!
>
> I hope someone can take the time to answer me and improve my
>
> ARP-skills
>
>
> and coding intuition :)
>
> Thanks a lot,
> Michiel van der Ros
>
>
>
>
>
>
>
>
>
>
>
>
> --
>
> [ weblog ][ http://michiel.vanderros.nl ]
>
> _______________________________________________
> Arp mailing list
> Arp at ariaware.com
> http://ariaware.com/mailman/listinfo/arp_ariaware.com
>
>
>
More information about the Arp
mailing list