Programming pattern / architectural question

前端 未结 6 1413
生来不讨喜
生来不讨喜 2021-02-10 13:50

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:24

    Rather than the IBAN number being a simple string, what if it was an actual class? You could implement validation in the constructor (if validation has no external dependencies), or you could use a factory to provide IBAN instances (if you need external validation). The important thing is that, if you have an IBAN instance, you know that it's a valid IBAN number.

    Should BankAccount actually have a mutable IBAN number? I'm not terribly familiar with banking, but that sounds like a scary idea.

提交回复
热议问题