can any one tell me what class architecture is best for bellow scenario ?
I have classes called "BasicAccount","SavingAccount" and "CurrentAccount"
"SavingAccount" and "CurrentAccount" should have all the features of "BasicAccount". latter it might be the case that we may introduce a new Account called "AdvanceAccount" it shoud have all the features of "CurrentAccount" and "SavingAccount". how should i design the structure ?
My answer: lets keep "BasicAccount" as Abstract,
SavingAccount is also Abstract which inmlement Basic account,
Create one interface "ICurrentAccount" and currentaccount implement Basicaccount and ICurrentAccount,
latter if we have AdvanceAccount then implement it with SavingAccount and ICurrentAccount
Is there any better way ?
this was me in one interview and interviewer was not satisfied with my answer i guess !!
Aucun commentaire:
Enregistrer un commentaire