posted 9 years ago
More concretely, I would probably try something like this:
If you inject the policies, you can easily add new AirlinePolicies externally, perhaps via Spring Framework DI. Whatever this class is, it provides the context in which the Policy operates, which is why you would pass a reference to this in the call to the applyTo method. Each Policy could potentially change the state of this object or if the conditions are not right to apply the policy, it can do nothing and simply return.
You could also pass in something like a Context object that will provide the information each Policy needs to operate. It all depends on the surrounding code how you end up refactoring.