0

currently I have an structure of PopUps and I've been thinking to use Chain of Responsibility pattern, but the difference is a popup can back to previous one PopUp and also can go to any other PopUp. I've been thinking to use chain of responsibility, but I think maybe is not the Ideal once chain of responsibility only goes forward.

Can you guys help me in this case? Which should be the best pattern? I thought something like a layer structure or something like.

Eg:

PopUp can go to Any other PopUp N  to N

7
  • Can you explain what is your goal and what is using these "Popup" thing ? Give real life example. – Alexander Petrov Feb 25 at 19:32
  • @AlexanderPetrov Client requested like a PopUp which you have category like Offer PopUp , after choose you keep going filtering like Offer PopUp ->Drinks PopUp -> Soda PopUp -> But Sometimes can also happen the client wants back to other one pop up, so I thought something like Layers or something – André Pietro Feb 25 at 19:42
  • When is the order finished? What is your end condition and there is no more ordering. Going to the end Of the meny? – Alexander Petrov Feb 25 at 20:03
  • @AlexanderPetrov Selected button will return an index, by the index the handler will choose to select a product which is an ending condition, or can choose other popup like "Back" button – André Pietro Feb 25 at 20:22
  • 4
    I would say this is more suitable for state machine, where one state(popup) has multiple triggers and when one of them triggered execution moves to another state(popup) – Fabio Feb 26 at 1:16
0

The chain of responsibility when executed does not know which element in the chain will do the processing. It is aways executed from the start. In your particular case you know where in the chain you stand when previous element , or next element is selected. In my opinion what you need is structure that has qualities of:

  1. Double link list - in Java that will be LinkedList.
  2. A good abstraction of a PopUp

You may want to create a structure that can list the elements, so that you can potentialy jump and not need to go the middle element when navigating.

0

Try to avoid unnecessary complexity. Any ordered collection (e.g. array) will allow you to go both forward and backward. The next question would be what to store in the collection to represent the 'pop ups.' Good luck!

0

That's too much responsibility for a simple pop-up: not only it has to present some data, but also manage it's own presentation and coordinate with siblings. Move all that unnecessary complexity somewhere.

It seems you are trying to build a menu, so just build a menu:

  • Simple data-driven menus that communicate through a parent or a controller.
  • One container to manage all the children, showing only one child at time.
  • Overlay container, to put menus above everything else, perhaps with mask.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.