Show in graph

Software → Software Design

Abstraction

The practice of hiding unnecessary detail behind a simpler concept, interface, or model.

Brief explanation

Abstraction means depending on the essential contract of something, not on every concrete detail. In code, that usually means the order workflow talks to capabilities such as PaymentProcessor or Notifier, rather than directly constructing Stripe, email, or logging details inside the workflow.

Code example
Bad example
Python
class StripePaymentProcessor:  def charge_card(self, amount: float) -> None:      print(f"Charging card through Stripe: {amount}")class EmailNotifier:  def send_email(self, message: str) -> None:      print(f"Email: {message}")class OrderService:  def checkout(self, total: float) -> None:      payment = StripePaymentProcessor()      notifier = EmailNotifier()      payment.charge_card(total)      notifier.send_email("Order confirmed")
Good example
Python
from typing import Protocolclass PaymentProcessor(Protocol):  def charge(self, amount: float) -> None:      ...class Notifier(Protocol):  def notify(self, message: str) -> None:      ...class StripePaymentProcessor:  def charge(self, amount: float) -> None:      print(f"Charging through Stripe: {amount}")class EmailNotifier:  def notify(self, message: str) -> None:      print(f"Email: {message}")class OrderService:  def __init__(self, payment: PaymentProcessor, notifier: Notifier):      self.payment = payment      self.notifier = notifier  def checkout(self, total: float) -> None:      self.payment.charge(total)      self.notifier.notify("Order confirmed")