Programming pattern / architectural question

前端 未结 6 2133
伪装坚强ぢ
伪装坚强ぢ 2021-02-10 13:34

I am currently working on a project where I have a BankAccount entity for some other entity.

Each bank account as a reference to a bank entity, an account number and opt

6条回答
  •  不要未来只要你来
    2021-02-10 14:20

    You can just use a delegate to validate, you don't need to pass a whole interface, who ever wants to set it has to have a validator.

    public delegate bool Validation(IBAN iban);
    void SetIBAN(IBAN iban, Validation isValid){ 
      if(!isValid(iban)) throw new ArgumentException();
    ...}
    

提交回复
热议问题