Low Level Design & OOP
Refactor a Cache for Pluggable Eviction Policies
Asked by:Bloomberg
object_modelinginterfacesextensibilitydesign_patternstesting
Problem Overview & Object Oriented Requirements
Refactor a working LRU cache into a generic in-memory cache that cleanly supports LRU, LFU, and future policies.
Design Principles: Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion (SOLID).
Topics & Patterns: object_modeling, interfaces, extensibility, design_patterns, testing.
Class Design Breakdown
1. Identify Core Entities
List primary objects, state enums, value objects, and domain controllers.
2. Class Relationships
Define inheritance, composition, aggregation, and interface abstractions.
3. Apply Design Patterns
Incorporate Strategy, Factory, Observer, State, or Decorator design patterns.
4. Concurrency & Extensibility
Handle thread locks, synchronization, and future extensions cleanly.