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 help me in this case? Which should be the best pattern? I thought something like a layer structure or something like.


PopUp can go to Any other PopUp N  to N

  • 2
    Can you explain what is your goal and what is using these "Popup" thing ? Give real life example. Feb 25, 2021 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 Feb 25, 2021 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? Feb 25, 2021 at 20:03
  • 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, 2021 at 1:16
  • 1
    does the popup2 depend on the choice made of popup1 ? Or is it still depending in the same initial event ?
    – Christophe
    Feb 26, 2021 at 7:17

3 Answers 3


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.


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!


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.