Banking System Interface Design - Interview

My experience: I am a recent graduate looking for work in the software industry. Question: I was in a recent interview with one of the software companies and asked to draw a UML diagram for a banking system that shows 2 accounts, for example. storage and verification, and they have another way of calculating interest.

My solution: I made the Account class an abstract class.
For example: public abstract class Account {......} This class has 2 methods defined in it deposit () and remove (), which is common to any type of account. another method is CalculateInterest (), which is an abstract method.

There are 2 storage and verification classes that extend the account class and implement the Account class. for example: public class Saving extends Account {...}

I added another class to complete UML, like a bank and bank location, but this did not satisfy the interviewer, and he wanted me to implement the whole process as INTERFACES , which I did not understand very well. I tried to extract the same information, but the interviewer did not like it.

Any information that people can share here will help me in understanding the design and further approach to the interview.
I know that they have many design templates that are there, but when he mentioned certain interfaces, I was not sure how to approach this.

0
design-patterns
source share
1 answer

In the normal banking process, you already give a great answer. However, for complex banking requirements, they will need a more modular design, and that is where the interface will shine.

In your basic design, you say that:

  • All account can make a deposit
  • All Account Can Do Withdraw
  • All Account Can CalculateInterest

Tell with your current design how this requirement is:

  • To create an account type that can only deposit . It cannot be withdrawn, only closed (for example, a temporary deposit).
  • To create an account type that can only withdraw . Say that you deposit some money when opening an account , then you can only withdraw , and at the end close it
  • To create an account type that can only CalculateInterest , but not deposit or withdraw .
  • And so on

In your design, you can inherit the base class account and throw unimplement exception for every unsupported action (deposit, etc.). However (please correct me), which violates the LSP and risks an exception at runtime.

Using an interface, you need to declare some interfaces:

  • IAccount (this has a basic property such as balance, user id, etc.)
  • IDepositable: IAccount
  • IWithdrawable: IAccount
  • IClosable: IAccount
  • ICalculateInterestable: IAccount

Then for the requirement, you can declare a class:

  • implementation of IDepositable, IClosable, ICalculateInterestable
  • implementation of IWithdrawable, IClosable, ICalculateInterestable
  • implementation of IClosable, ICalculateInterestable

This may not be the most thoughtful design, but it should satisfy most banking requirements.

+2
source share

All Articles