Step 01The Setup
Clarify Requirements
Never start coding immediately. Define the scope, actors, and constraints.
Identify Actors (Admin, Customer, System) Define Functional Reqs (What system does) Define Non-Functional Reqs (Concurrency?) Clarify Scale (Is it distributed?) "Ask: 'Are we designing a single machine or distributed system?'"
Step 02Structure
Define Entities
Extract core objects from the requirements. Look for nouns.
List Nouns (e.g., Ticket, Spot, Vehicle) Identify Enums (Status, Type) Ignore implementation details for now "Write nouns on the whiteboard immediately."
Step 03Interface
Define APIs / Behaviors
Define how the outside world interacts with your system.
Define Entry Points (park(), pay()) Define Return Types & Exceptions Interface Segregation Principle "Focus on the contract, not the logic inside."
Step 04Architecture
Establish Relationships
Connect the entities using Composition, Aggregation, and Inheritance.
ParkingLot HAS-A Levels (Composition) Car IS-A Vehicle (Inheritance) User USES-A Gate (Association) Check cardinality (1:1, 1:N) "Prefer Composition over Inheritance."
Step 05Optimization
Apply Design Patterns
Refactor the structure to handle change and complexity.
Creation complexity? -> Factory/Builder Varying algorithms? -> Strategy Notifying users? -> Observer Global access? -> Singleton (Use carefully) "Don't force patterns. Only solve specific problems."
Step 06Implementation
Code & Concurrency
Write clean, thread-safe code handling edge cases.
Handle Locks/Synchronization Validate Inputs (Fail Fast) Handle Exceptions Gracefully Write a Main/Driver class to test "Mention 'Thread Safety' even if not asked."