mardi 18 février 2020

What could be a better way to design bank application [closed]

I have to create a bank application in OOP way that supports: Withdraw, Deposit, Maintain Transaction List. I have come up with following class:

 1. Transaction:
         *Properties*:
            TransactionType(Debit/Credit)
            Amount
            DateTime
 2. Account
         *Properties*:
            Id
            List<Transaction>
         *Methods*:
            withdraw
            deposit
 3. Customer
         *Properties*:
            Id
            Name
            List<Account>
 4. Bank
         *Properties*:
            List<Customer>

Now to add customer and add account I have created CustomerService and AccountService respectively And to withdraw and deposit I have created WithdrawService and DepositService(I could create TransactionService to include both)

Problem: Lets say user want to deposit $100

Client of DepositService ( e.g. controller in case of mvc) would call deposit method of this DepositService and would pass in AccountId But I don't have ready collection of Account objects to get Account object for this AccountId instead I have collections of Customers in Bank class. So I could not directly get Account object and deposit amount to it. So I have come up with following ways:

  1. Pass in customerId and accountId to deposit method of DepositService, then DepositService get Customer object and then get Account object from that Customer object.
  2. Keep List of Accounts in Bank class instead of list of Customer and get Account directly from this list and deposit amount. But in this case where to maintain customer list? Because Account would have customerId in that case and not Customer object. Now I need to keep map of customerId and Customer object but where to keep this map?

What could be better way to solve this problem?

Aucun commentaire:

Enregistrer un commentaire