robotlegs multiview project structure

ismail's Avatar

ismail

05 Mar, 2015 05:27 PM

I started to learn robotlegs. I write a lot of code samples. Then I wrote my own code my myself.

I want to do that:

1. login user with a "login panel".
2. after login user should see a "dashboard".
3. On dashboard there are several buttons. User can click them.
4. If User click a "statistics button" "statistics panel" will shown in dashboard content area (based on VGroup).
5. If user click another button then another panel should show. Of course existing panel will removed.

I create a structure for that but I am not sure I doing it correctly. It works but when it will grow and get bigger will it get trouble for me?

I added my project. Could you look my structure and give me some suggestions?

Thank you for your effort.

  1. Support Staff 1 Posted by Ondina D.F. on 05 Mar, 2015 06:08 PM

    Ondina D.F.'s Avatar

    Hi Ismail,

    My FlashBuilder can't import your project for some reason. Please, just attach a zip file containing your project classes, without the flashbuilder settings and config files.
    I'll take a look at your project tomorrow and let you know about my findings.

    Ondina

  2. 2 Posted by ismail on 05 Mar, 2015 06:12 PM

    ismail's Avatar

    Hi Ondina.

    Thank you for your interest.

    Here is the zip file:

  3. Support Staff 3 Posted by Ondina D.F. on 06 Mar, 2015 11:04 AM

    Ondina D.F.'s Avatar

    Your project's structure looks good. It shows that you already understand the basics of robotlegs and mvcs. Well done:)

    You use interfaces for views, which I think is good. You're not using any models yet, but when you'll do, try to use interfaces as well. Same thing for services.

    You have a dispose method in your views, where you remove dependencies and listeners, which is very good in terms of garbage collection.

    You use a VO to transport data between classes, which is also very good.

    You use a config file for each 'module', which I find to be the best way to organize the configuration of classes in a large application.

    So, all in all, you are on the right path :)

    I create a structure for that but I am not sure I doing it correctly. It works but when it will grow and get bigger will it get trouble for me?

    What kind of trouble are you expecting? What exactly makes you worry?

    In my experience, a 'modular' structure, like the one you used, is best suited for large projects.

  4. 4 Posted by ismail on 06 Mar, 2015 11:30 AM

    ismail's Avatar

    I am very happy to all good news from you. Thanks for your analysis :)

    I expect or I confuse about that:

    I am trying to code an aministration panel. There will be a lot of views like "Project Managment", "User Managment" etc.

    In my Main class should I define them like that:

    context = new Context()
    .install(MVCSBundle, SignalCommandMapExtension)
    .configure(AppConfig)
    .configure(WrapperConfig)
    .configure(LoginPanelConfig)
    .configure(ProjectsPanelConfig)
    .configure(UsersPanelConfig)
    .configure(SomeDifferentPanelConfig)
    .configure(VeryInterestingPanelConfig)
    .configure(WeNeedThatPanelConfig)
    .configure(JustForHelloWorldPanelConfig)
    .configure(new ContextView(this));

    If I will code like that my I suppose my application will use a lot of system source. Or maybe that is what the solution is. I do not know. It is made me confused.

    I am so grateful for your answer. Thank you very much again.

  5. 5 Posted by ismail on 06 Mar, 2015 12:13 PM

    ismail's Avatar

    And the other confusing point is, where should I do the form validation or the other logical codes (for each loops, string trims, array splice etc)? In mediator? I do not think so. In view. It can not be. In commands?

    With these questions answers I will contuniue coding. I guess my mind will be very clear with your answers.

    Thank you again.

  6. Support Staff 6 Posted by Ondina D.F. on 06 Mar, 2015 02:38 PM

    Ondina D.F.'s Avatar

    You're welcome, Ismail! I'm glad I could help.

    If I will code like that my I suppose my application will use a lot of system source.

    The config classes that implement IConfig get garbage collected after the context has been initialized. You can see that if you use a profiler, like the FlashBuilder Profiler.

    Views and Mediators get garbage collected when the views are removed from stage.

    Commands get garbage collected immediately after execution.

    Events aren't kept in memory. With Signals you have to take care yourself of removing listeners, but it seems that you've already understood how to do that.

    Models injected as interfaces into Commands get garbage collected.

    Depending on your projects requirements you might want to use swf modules. With the structure you intend to have for your project, it is really easy to create modules out of the classes under one package. For example, you could decide to have a login module, that you load when the app starts and unload when the user logged in successfully . Each module has its own context, which is created when the module is added to the stage, and destroyed when the module is removed from stage. The module with all its classes gets garbage collected.

    And the other confusing point is, where should I do the form validation or the other logical codes (for each loops, string trims, array splice etc)? In mediator? I do not think so. In view. It can not be. In commands?

    Yeah, that's a good question, but quite difficult to answer. The Mediator is the wrong place for validation in my opinion, too.

    There are many opinions about the right place for form validation. In part, it depends on the overall design of your app, on your preferences and on the type of validation.

    Some prefer to do that inside the view. Some others do it in a command.

    I prefer to use helper classes for validation of input fields, like empty fields checking, length of a string, email check, trimming strings, etc and other operations.
    Now, how you use these helper classes, is up to you.
    You can inject them into a mediator, which will pass them to the view.

    Or, you can inject them into a command and send the data to be validated (VO) via an event from the view->-mediator->command->helper class. You can create different commands for different kinds of validation, if you want. For example an EmailValidationCommand that calls a validateEmail() method on the helper class.

    Or you could have the validation logic inside a command.

    Another approach could be to have the views extend a base view, which has a set of validation methods.

    As I said, it's hard to say what's best, because it depends on too many factors. A very simple operation, like just trimming an input string, isn't worth the effort of dispatching an event with a vo->mediator->command->helper class->event->mediator->view.
    The input field itself could be a component extending a base component with this functionality already included (on focus out ->trim string).
    On the other hand, if you're doing lots of validations, checking and manipulation of the input data, I'd consider using a helper class, either used by the view itself or inside a command.

  7. 7 Posted by ismail on 07 Mar, 2015 04:30 PM

    ismail's Avatar

    Thank you again Ondina. This is very helpful and clear. I can use Robotlegs without any trouble now.

  8. Support Staff 8 Posted by Ondina D.F. on 09 Mar, 2015 10:31 AM

    Ondina D.F.'s Avatar

    Once again, you're welcome, Ismail!
    Enjoy and have fun with robotlegs :)

  9. Ondina D.F. closed this discussion on 09 Mar, 2015 10:31 AM.

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