Navigation Question : Buttons

thomas.thorstensson's Avatar

thomas.thorstensson

17 May, 2011 11:11 AM

I been thinking about the best practice for navigation elements in RL.

One Idea I have, and forgive me if this is a very simple question, is to have a separate NavView class mediated by NavViewMediator. When a button is clicked in NavView the mediator updates the Model with the new state and Model dispatches a SystemEvent that ContentViewMediator catches and updates ContentView. So far so good ?

My question now is what about the Navigation buttons themselwes. Should they be compartmentalized as in : the code for a Button put inside the view.components package as a new package below components? This will most likely only be one class that could for example extend SimpleButton ?

So my question is what is the best strategy for where to put Navigation buttons ?

Thanks on beforehand

Thomas

  1. 1 Posted by krasimir on 17 May, 2011 11:19 AM

    krasimir's Avatar

    Maybe it is not necessary to create a class for every button. So the idea with NavView + NavViewMediator is good, but I don't think that updating the model from the mediator is the best practice. Usually I'm dispatching an event from the mediator to the event bus and there is a command which is mapped to this event. Actually the command updates the model or directly changes the content.

  2. 2 Posted by thomas.thorsten... on 17 May, 2011 12:13 PM

    thomas.thorstensson's Avatar

    Yes I forgot that I actually also update Model via Commands only.

    But then to the main question. If I have ony class only (for all buttons) for things like hoover,roll out and whatnot.

    Should I compartmentalize it, as in create a package named button inside view.components package ?

    Remember NavView and NavViewMediator goes where they should so Im clear over that.

    But what about the button class itself for the buttons that NavView contain. Should I compartmentalize it so that NavView compoes/instantiates the button using the new keyword? Lol

    Thanks

    Thomas

  3. 3 Posted by krasimir on 17 May, 2011 12:23 PM

    krasimir's Avatar

    To be honest in 80% of the cases I'm using one class to manage a navigation component like yours. I mean if I have a simple menu with few buttons. In the rest 20% I have more complex logic like drop-down menus or some animations of the buttons. In such kind of cases it is good to have a specific class for the buttons. I guess it depends of the type of your navigation.

  4. 4 Posted by thomas.thorsten... on 17 May, 2011 12:40 PM

    thomas.thorstensson's Avatar

    I see , but in those more complex cases you would seal that off from the rest of the application yes ? For example (good point !) in the case of a Menu with Sub Menu.

    Thanks for the speedy replies

    Thomas

  5. Stray closed this discussion on 07 Jun, 2011 01:31 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