:)
I got such a question, I am learning Java and having an excercise where I have to design some small "bank" app.
Task sounds liek that:
Client should be able to create payment of one of 3 types - TYPE1,
TYPE2, TYPE3. Fields 'amount' (positive decimal), 'currency' (EUR or
USD), 'debtor_iban' and 'creditor_iban' (texts) are mandatory for all
types. Additional type-specific requirements: TYPE1 is only
applicable for EUR payments, has additional field 'details' (text)
which is mandatory; TYPE2 is only applicable for USD payments, has
additional field ‘details’ (text) which is optional. TYPE3 is
applicable for payments in both EUR and USD currency, has additional
field for creditor bank BIC code (text) which is mandatory.
At this moment I am looking for a correct design solution. Currently I have my primary idea being this one:
I got one Payment class which has two Enums inside, Currency Enum which holds USD and EUR values and Type enum that holds Type1,Type2,Type3 values. Another ideas was to have 1 supertype and 3 types that extend supertype class, but then it would be 3 different tables in the databes with no relationships and in this case I won't be able to make proper qureries to extract all Payments from 3 tables, I believe.
Would appreciate any tip as I know that "bank apps" require way more proper design than just building it blindly.
Asking You kindly to give me a suggestions with an explanation, when and which case serves this task needs better.
take care! :)
Aucun commentaire:
Enregistrer un commentaire