Python Abstraction Foundation
abstract / interface OOP 03 Foundation

Hide complexity behind simple interfaces

Abstraction shows only essential features and hides complex internal details from the user.

Picture this: hide the engine, show the button

You call a simple method. The messy details stay inside the class.

youpress start()
→
public methodsimple name
→
hidden stepsinside class
→
resultit just works

What is abstraction?

Abstraction means exposing only the necessary details and hiding the internal complexity. You interact with the interface, not the implementation.

UML Abstraction Diagram

classDiagram
    class BankAccount {
      +deposit(amt)
      +withdraw(amt)
      -_validate()
      -balance: int
    }
    note for BankAccount "Public: deposit(), withdraw()\nPrivate: _validate(), balance" as N1
            
Public methods form the interface; private methods/data are hidden.

Interface vs Implementation

Public Interface Hidden Details
User interacts with the interface, not the hidden implementation.

Real-world analogy

You drive a car by using the steering wheel, pedals, and buttons. You don't need to know how the engine works. The complex internal details are hidden behind a simple interface.

Public Interface

  • Methods users interact with
  • Simple and clear
  • What matters externally

Hidden Details

  • Internal helper methods
  • Complex algorithms
  • Implementation specifics

Abstraction example

1class BankAccount:
2def deposit(self, amt): # PUBLIC
3self._validate() # Hidden
4self.balance += amt
5def _validate(self): # PRIVATE
6# Complex validation logic

What user sees

Press "Run one step" to see abstraction layers

Usage (simple for user)

1account = BankAccount()
2account.deposit(100) # Easy to use!
3# Internal validation is hidden