Skip to content
Low Level Design Mastery Logo
LowLevelDesign Mastery

Abstraction

Hide complexity, expose only what's essential.

Abstraction is the concept of hiding complex implementation details and showing only the essential features of an object. It helps reduce complexity and increase efficiency by allowing users to interact with objects at a higher level without worrying about internal implementation.

Abstraction focuses on what an object does rather than how it does it. It provides a simplified interface to complex systems.

Think of a car:

  • What you see: Steering wheel, pedals, gear shift
  • What’s hidden: Engine mechanics, transmission system, fuel injection

You don’t need to know how the engine works to drive the car - that’s abstraction!

Abstract classes cannot be instantiated directly and must be subclassed. They define a contract that subclasses must follow.

classDiagram
    class Shape {
        <<abstract>>
        +area()* float
        +perimeter()* float
        +describe() str
    }
    
    class Rectangle {
        -width: float
        -height: float
        +area() float
        +perimeter() float
    }
    
    class Circle {
        -radius: float
        +area() float
        +perimeter() float
    }
    
    Shape <|-- Rectangle
    Shape <|-- Circle
    
    note for Shape "Abstract class\nCannot be instantiated"

You can also define abstract properties:

  • Use abstraction to create flexible, maintainable code that can work with multiple implementations

Abstraction is about creating a contract that all implementations must follow, while hiding the complexity of how each implementation works internally.

💡 Time to Practice!

Now that you understand the concepts, put them into practice with our interactive playground. Build UML diagrams, write code, and get AI-powered feedback.

Browse All Problems