I am trying to design my classes for a calculator. I am using the Command Pattern to execute operations on a stack to evaluate expressions. The Commands are created through an Abstract Factory. My problem is deciding how the Commands should get the receiver (the stack). Is it ok to pass a reference to the stack through the factory and then pass that to my Commands? I think there should be a better way rather than changing the interface of the factory.

Aucun commentaire:
Enregistrer un commentaire