Check up
Hello.
I've been porting a small simplified slideview (load an xml of
pictures and use a timer to go thru them) into RL and I would like
to know from you if I'm in the right path in the process of
learning RL or not. It works now but I'm not sure at all about my
work. Any consideration or/and opinion will be very welcomed.
Thanks.
- SlideView.zip 939.5 KB
Comments are currently closed for this discussion. You can start a new one.
2 Posted by jadd on 03 Mar, 2010 07:06 AM
I know that none have time to loose but please. thx.
Support Staff 3 Posted by Shaun Smith on 03 Mar, 2010 05:45 PM
Hi Jadd,
I'm afraid that it takes a lot of time and energy to do a proper code review. From first glance it looks like you're on the right track. I did notice a couple of things though:
Proxies vs Models vs Services: I don't see a service layer in your application. You should use services to interact with external data. Also, I see that you're got both a DataModel and a DataProxy. It's hard to tell by looking at the files from the outside what the difference is between the two. With Robotlegs we've got rid of the notion of Proxies in favour of Models.
SlideviewMediator: the mediator seems to have too many responsibilities. Also, it is holding state for the view (autoPlay, duration, _isTimed etc). The view should contain it's own state, and expose that to the mediator via an API.
Event typing: you should use the 4th parameter of eventMap.mapListener() to ensure that your event constants don't clash.
Naming: SetDataCommand, for example, is way too generic - it could do anything. And your bootstrap command's could be better named too: ViewCommand could be called MapViewCommand or InitializeViewCommand for example.
That's it for now! As I said, I don't have much time to review code at the moment, so these are just things I spotted quickly.
4 Posted by jadd on 03 Mar, 2010 06:36 PM
Hi Shaun,
I'm sorry I don't wont to bother anyone with my (stupid things!). I know that it's hard to have time for help others. But thank you a lot for the reply. I'm not sure (at my stage of learning!) I can follow your intensions properly:
1 - Maybe my proxie could be named loadXmlService (its that what you mean?).
2 - RL best practice reads: "Mediator is responsable for the logic" (more or less) and i tried to put all my logic in there.
3. I used it (but i will take a more in depth look at the doc).
4. I will use the last one you named.
I'm glad to hear that i'm in right side!!
May i say one thing more about this help support!? The "solutions" part of this help support is delosated empty! Why?
Thank again.
Support Staff 5 Posted by Shaun Smith on 03 Mar, 2010 07:58 PM
Hi Jadd,
Yes, I would rename the Proxy to Service. But again, LoadXmlService is very generic and could mean anything. A more specific name would be better; what does the service do? It loads Slides. So, perhaps:
ISlideDataService - the service contract
SlideDataXmlService - an implementation that deals with XML
SlideDataJsonService - an implementation that deals with JSON
Also, your model deals with XML internally. The purpose of the service layer is to translate the external data (in this case: XML) into a format that is natural to your application model. This is so that you can swap the service (to JSON, or AMF for example) without having to change your model. It's the services job to load AND translate the data.
Also, I wouldn't pass the url to the load() method - what will happen when you switch to another service? You will need to change that url. Instead, I would pass the url to the service on construction (or after construction via another public method: setURL perhaps), and elsewhere in your app just call service.load(). That way each service can point to a different url and you don't need to edit the places in your app where you call load(), but rather just the one place where you configure the service.
Mediators, most of the time, should just be passing messages between the application and the view. It's job is to translate messages (and payloads) between the two. Sometimes it's ok to have a bit of logic in the mediator, but usually it's better for the view to encapsulate it's own behavior.
As for the "solutions" section being mostly empty: when we set this site up we put most of those kinds of things (solutions) into the FAQ. The solutions section is for anyone in the community to add to. Robotlegs is still very new, so I think it will take some time to fill up that area :)
6 Posted by jadd on 10 Mar, 2010 06:55 AM
HI all.
Don't curse me, I'm here again with modified version of my slideview (As3 pure project made with Flash builder) and I hope the last one. Again if someone want to share suggestions/opinions. Thank.
jadd closed this discussion on 15 Nov, 2010 09:46 AM.