Skip to main content

Command Palette

Search for a command to run...

Popular Object Oriented Design Problem — Design ATM Machine

Updated
4 min read
Popular Object Oriented Design Problem — Design ATM Machine
B

bugfree.ai is an advanced AI-powered platform designed to help software engineers master system design and behavioral interviews. Whether you’re preparing for your first interview or aiming to elevate your skills, bugfree.ai provides a robust toolkit tailored to your needs. Key Features:

150+ system design questions: Master challenges across all difficulty levels and problem types, including 30+ object-oriented design and 20+ machine learning design problems. Targeted practice: Sharpen your skills with focused exercises tailored to real-world interview scenarios. In-depth feedback: Get instant, detailed evaluations to refine your approach and level up your solutions. Expert guidance: Dive deep into walkthroughs of all system design solutions like design Twitter, TinyURL, and task schedulers. Learning materials: Access comprehensive guides, cheat sheets, and tutorials to deepen your understanding of system design concepts, from beginner to advanced. AI-powered mock interview: Practice in a realistic interview setting with AI-driven feedback to identify your strengths and areas for improvement.

bugfree.ai goes beyond traditional interview prep tools by combining a vast question library, detailed feedback, and interactive AI simulations. It’s the perfect platform to build confidence, hone your skills, and stand out in today’s competitive job market. Suitable for:

New graduates looking to crack their first system design interview. Experienced engineers seeking advanced practice and fine-tuning of skills. Career changers transitioning into technical roles with a need for structured learning and preparation.

Design ATM is a typical Object Oriented Design question in software engineer interview, for testing if an engineer can abstract the actual objects and functionalities in the sense of system architecture.

System Design Diagram — Design ATM Machine

1. Requirements Definition

Functional Requirements:

  • Authenticate users and allow access to their accounts.
  • Support key operations like withdrawals, deposits, balance inquiries, and transfers.
  • Dispense cash and print receipts.
  • Allow multi-language user interfaces.

Non-Functional Requirements:

  • Ensure high availability and fault tolerance.
  • Provide strong security for user authentication and transaction data.
  • Support scalability for future user base and feature expansion.
  • Handle concurrent operations without compromising consistency.

2. Core Entities Identification

The system can be modeled around the following primary entities:

  1. ATM: Represents the physical ATM machine, responsible for interfacing with users, handling hardware interactions (card readers, cash dispensers, printers), and connecting to the central server.
  2. User: Represents the person interacting with the ATM, identified through a bank card and PIN or biometric data.
  3. Account: Represents a financial account (savings, checking) associated with a user.
  4. Transaction: Models financial operations like withdrawals, deposits, and balance inquiries.
  5. Bank: Represents the organization managing accounts, user data, and transaction validations.
  6. Card: Represents the physical debit/credit card used for authentication and linking to the user account.

3. Entity Relationships and Use Cases Establishment

Entity Relationships:

  • ATM interacts with User via Card to authenticate and perform transactions.
  • User owns one or more Accounts.
  • Each Transaction is associated with one Account and logged for audit purposes.
  • ATM communicates with the Bank for operations requiring centralized validation (e.g., account balance checks, transaction authorization).

Use Cases:

Primary Use Cases:

  • Authenticate User: Insert card -> Verify credentials -> Retrieve associated accounts.
  • Withdraw Cash: User selects account -> Enters amount -> ATM validates and dispenses cash -> Logs transaction.
  • Deposit Cash: User inserts cash -> ATM validates -> Updates account balance -> Logs transaction.
  • Balance Inquiry: User selects account -> ATM retrieves balance from the bank -> Displays on screen.

Secondary Use Cases:

  • Failure Scenarios (e.g., card retention on multiple incorrect PIN entries).
  • Maintenance Activities (e.g., refilling cash, hardware diagnostics).

4. API Design

ATM Interface:

class ATM {
boolean authenticateUser(Card card, String pin);
Transaction performTransaction(User user, TransactionType type, double amount);
double checkBalance(Account account);
void dispenseCash(double amount);
void depositCash(double amount);
void printReceipt(Transaction transaction);
}

Bank Interface:

class Bank {
boolean validateUser(Card card, String pin);
boolean authorizeTransaction(Transaction transaction);
double fetchAccountBalance(Account account);
void updateAccountBalance(Account account, double amount);
void logTransaction(Transaction transaction);
}

Transaction Class:

class Transaction {
String transactionId;
Date timestamp;
TransactionType type; // WITHDRAWAL, DEPOSIT, INQUIRY
double amount;
Account account;
TransactionStatus status; // SUCCESS, FAILURE
}

5. Request Flows

a) User Authentication:

  • ATM reads the card, prompts for a PIN, and forwards authentication to the Bank API.
  • The Bank validates credentials and returns user details.

b) Transaction Request:

  • User selects “Withdraw,” specifies account and amount.
  • ATM checks cash availability locally and requests authorization from the bank for the withdrawal.

c) Transaction Execution:

  • On approval, the ATM dispenses cash and prints a receipt.
  • The Bank updates the account balance and logs the transaction.

d) Error Handling:

  • If cash is unavailable or authorization fails, the user is notified, and no money is dispensed.

6. Scalability and Flexibility Consideration

Scalability:

  • Use a distributed architecture to offload transaction handling from a single server.
  • Introduce load balancers for handling peak transaction loads.
  • Deploy edge servers for faster local processing of non-critical requests (e.g., PIN validation).

Flexibility:

  • Design modular components to support future hardware (e.g., NFC readers, biometric scanners).
  • Implement feature toggles for smooth rollout of new functionalities (e.g., voice-guided interface).

7. Failure Scenarios Analysis

User Errors:

  • Forgot PIN: Allow limited retries with account lockout after three failed attempts.
  • Incorrect Inputs: Provide clear instructions and the ability to cancel operations safely.

Hardware Failures:

  • Cash Jam in Dispenser: Detect and report the issue, preventing deduction from the user’s account.
  • Card Reader Failure: Notify users and flag the ATM for maintenance.

Network Failures:

  • Implement a retry mechanism for transient failures and queue transactions locally for delayed processing when communication with the bank is restored.

Software Failures:

  • Use robust exception handling and fail-safe mechanisms to ensure the ATM remains operational for basic tasks.

Full Answer: https://bugfree.ai/practice/object-oriented-design/atm-machine/solutions/zFg9xkuDXgLG5Mem

System Design Answer — Design ATM Machine

More from this blog

B

bugfree.ai

394 posts

bugfree.ai is an advanced AI-powered platform designed to help software engineers and data scientist to master system design and behavioral and data interviews.