I'm working on a CreditCardPayment context, and found this possibility that not all roles are needed for some context methods. For example, the method CreateSecurityHash
may require all roles, but VerifyHash
only requires one. Is it ok not to bind all roles? If so, what about introducing multiple constructors and only bind what's needed, like this:
public CreditCardPayment(objectA, objectB, objectC)
{
BindRoles(objectA, objectB, objectC)
}
public CreditCardPayment(objectA)
{
BindRoles(objectA, null, null)
}
It feels difficult though to know what context methods are allowed to call when doing this. So I'd like to know:
- Is this still ok (if so, why?), or
- Is the whole scenario a sign that another context is needed, or
- Should I keep the context and supply all objects needed for the roles, always?