Skip to main content
1 of 6
Despertar
  • 603
  • 5
  • 7

I think this approach is over-using inheritance which adds additional (unnecessary) complexity. Favor composition over inheritance when possible.

You could include everything you need to into a single class, and based on the result you can use the properties accordingly. For example if Result is false, then you could alert the user which criteria it failed on. If it's true you can give them the new password with the expiration date.

The client will not have to do any down casting based on property values which may be seen as a code smell.

class ChangePasswordResult { bool Result { get; private set; } string NewPassword { get; private set; } DateTime ExpirationDate { get; private set; } public bool WasPasswordLongEnough { get; private set; } public bool DoesPasswordHaveToContainNumbers { get; private set; } } 
Despertar
  • 603
  • 5
  • 7