RobotLegs Example – Clock App

simone's Avatar

simone

04 Sep, 2010 07:31 PM

An implementation of one of the most simple yet clear example of a MVC application:
A clock which can display the time in different ways.

article: http://blog.vizio360.co.uk/2010/04/robotlegs-example-clock-app/
git repo: http://github.com/vizio360/RobotLegs-Clock-App-Demo

  1. 1 Posted by blockage on 08 Sep, 2010 06:43 PM

    blockage's Avatar

    Thanks for the example. I'm pretty new to this framework but it seems like you have a lot of view stuff being done weird places. I think this'll make it pretty hard to reuse with different views.

    • AddClocks command -- A command shouldn't create views and add them to the display list directly. I'd have the parent view handle this, possibly in response to a call from its mediator.

    • AlignClocksOnStage command -- Why have a command for aligning the clocks? Seems like this is a view thing too. No need for this command IMO.

    • ClockAppMediator -- shouldn't set x/y positions. Layout is the also the views responsibility. I'd probably do something like, have the view expose a centerChildren() method.

    • SetupStage -- also a view thing. I'd just do this in creationComplete.

    If you want to explore the controller/commands a bit more, how about adding a UI for setting the time?

  2. 2 Posted by simone on 15 Sep, 2010 09:08 PM

    simone's Avatar

    Hi,

    thanks for the reply, I'm going to think about your comments and change the app where appropriate.

    I will post an update soon.

    Simone

  3. 3 Posted by simone on 16 Sep, 2010 07:12 PM

    simone's Avatar

    Hi,

    I've pushed a new branch called blockageReview and here is the repo

    git@github.com:vizio360/RobotLegs-Clock-App-Demo.git

    where I think I fixed all the issues you raised in your review.

    AddClocks command -- A command shouldn't create views and add them to the display list directly. I'd have the parent view handle this, possibly in response to a call from its mediator.
    --- Maybe I'm not getting it right, but somewhere in the code I will need to create the Views, and I don't really want to inject them into the mediator as I don't want to tightly couple the Main View Mediator with its children, but I agree with you that I shouldn't modify a view directly in a command. What I've done is creating a command for each view creation, which dispatches an event which then the Main App view is listening to.

    AlignClocksOnStage command -- Why have a command for aligning the clocks? Seems like this is a view thing too. No need for this command IMO.
    --- I made this decision because I found easier to locate where things are done by looking at the commands name, but I can see your point, and I agree so I moved this responsibility to the main app view.

    ClockAppMediator -- shouldn't set x/y positions. Layout is the also the views responsibility. I'd probably do something like, have the view expose a centerChildren() method.
    --- as mentioned above I moved it into the main app view.

    SetupStage -- also a view thing. I'd just do this in creationComplete.
    --- here I thought about treating the stage as a view so I've created a mediator specifically for the Stage. The stage can be seen as the DisplayObject at the top of the display list so why not treat it as a view?

    about expanding it so to be able to change the time, I need to work on it but it won't be soon..

    thanks for spending time looking at my code, and yet again there is always stuff to learn :)

    cheers
    Simone

  4. Support Staff 4 Posted by Ondina D.F. on 17 Sep, 2010 10:58 AM

    Ondina D.F.'s Avatar

    @Simone

    Inspired by your pretty clock I started working on an analog clock for Flex & AIR, which I want to use in one of my projects.
    I used your script for the time and clock’s hands settings.
    In my example the time’s setting occurs in the view.
    The Clock is customizable.
    I use Models + Commands for setting the time-zone and the styles (colors, logo) of the clock.

    My goal is to be able to add different Clocks to the application, each showing a different time and eventually having different looks.

    Also it would be nice if I could add a starting time (for example: the moment I start working on a project).
    The clock’s Face would change, i.e. circular sectors in a different color would show the time elapsed. By the end of the day (or night) or whenever I stop working the elapsed time should be inserted into the DB table for that project. Hmmm, I wish I could explain it better.

    Maybe we (and others) should try to collaborate and make 3 versions of the clock: Flash, Flex and AIR.

    My Clock has several weak points at this stage:

    • one of them is the positioning of the clock’s components, which is a real mess

    • there is no input validation for the form used to customize the clock

    • the time zone offset is just an array set in the Model - it should be a real list of time zones

    • I need a better solution for the drawing of circle sectors and the curved text

    Of course there are more things that should to be improved. It’s a work in progress.

    I hope to hear everyone's opinion and/or suggestions :)

    http://ondina.github.com/clock/RobotlegsClock.html

    http://github.com/Ondina/robotlegsclock

    Ondina

  5. Stray closed this discussion on 16 Feb, 2011 08:59 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac