Skip to main content
1 of 4
JimmyJames
  • 28.9k
  • 3
  • 55
  • 105

Neither of the options you have presented are good OO. Here's the simple OO answer to your question (may not be valid C#):

interface IAccount {
  bool CanResetPassword();

  void ResetPassword();
}

public class Resetable {
  public bool CanResetPassword() {return true;}

  public void ResetPassword() {/* RESET PASSWORD */}
}

public class NotResetable {
  public bool CanResetPassword() {return false;}

  public void ResetPassword() {throw new YouCantResetPassword();}
}
JimmyJames
  • 28.9k
  • 3
  • 55
  • 105