lundi 25 septembre 2023

Which design pattern should I use to have a "context" in my app?

I am developing an app with an ActionController. It handles a Queue, which stores Action objects. All it does is dequeue an Action, execute it, then execute the following Action etc. If there are no Action instances, it waits for one to queue.

These actions do not know themselves, so I would need a pattern to keep track of the higher level stuff, such as knowing where the program is in a process, which is composed of actions.

Actions should have access to this Context object to update it.

I have read about the Context Pattern, but I don't think it fits my needs because the Context object will have some logic, checking program state and alter actions in the queue.

A Singleton may be a solution, but I would like to have the cleanest architecture possible.

What are your thoughts?

Thanks

I read about Design patterns, specifically Context Object and Singleton but I don't think they fit my needs or are the cleanest way to organize my program.

Aucun commentaire:

Enregistrer un commentaire