惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
U
Unit 42
aimingoo的专栏
aimingoo的专栏
Engineering at Meta
Engineering at Meta
博客园 - 聂微东
小众软件
小众软件
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recent Announcements
Recent Announcements
罗磊的独立博客
MongoDB | Blog
MongoDB | Blog
Stack Overflow Blog
Stack Overflow Blog
博客园_首页
M
MIT News - Artificial intelligence
博客园 - 司徒正美
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
IT之家
IT之家
C
Check Point Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tailwind CSS Blog
D
Docker
Microsoft Security Blog
Microsoft Security Blog
Google DeepMind News
Google DeepMind News

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
LLD Object-Oriented Design: Thinking in Objects, Not Code
Saras Growth · 2026-05-19 · via DEV Community

Low-Level Design is not about writing classes or memorizing patterns.

It is about a fundamental shift in thinking:

Designing systems as a collection of responsibilities, not functions.

Most beginners start with code:

  • functions
  • APIs
  • logic

But real system design starts before that. It starts with how you model the problem itself.


Why Object Thinking Matters

A system designed around functions tends to:

  • scatter logic across multiple places
  • lose control over state
  • become hard to modify safely

A system designed around objects tends to:

  • keep data and behavior together
  • enforce rules at one place
  • make behavior predictable

The difference is not syntactic—it is structural.


The Wrong Mental Model (Function-Centric Design)

deposit(account, amount)
withdraw(account, amount)
update_balance(account)

Enter fullscreen mode Exit fullscreen mode

At first glance, this looks simple and readable.

But it raises deeper design issues:

  • Who owns the account state?
  • Where are validation rules enforced?
  • What prevents invalid updates?
  • What happens when business rules change?

The logic is distributed, not owned.


The Correct Mental Model (Object-Centric Design)

class BankAccount:
    def deposit(self, amount):
        ...

    def withdraw(self, amount):
        ...

Enter fullscreen mode Exit fullscreen mode

Now the design changes fundamentally:

  • state and behavior are encapsulated together
  • rules are enforced inside the object
  • external code interacts through controlled methods

The system becomes self-governing at the object level.


Core Idea: Responsibility Ownership

The most important question in object-oriented design is:

Which object owns this responsibility?

Not:

  • where should this function go
  • how should I structure files
  • how many layers should I create

Instead:

  • which entity is responsible for this behavior in the domain?

This shift determines the quality of the entire design.


Objects Represent Real-World Systems

A good mental model is to map systems into interacting entities:

Example: Food Delivery System

  • User → initiates actions
  • Restaurant → prepares food
  • Order → maintains lifecycle state
  • DeliveryPartner → fulfills delivery

Each object:

  • owns state
  • exposes behavior relevant to its responsibility
  • does not manage unrelated logic

Class vs Object (Core Understanding)

Class

A blueprint that defines structure and behavior.

Object

A real instance with actual state.

class BankAccount:
    def __init__(self, balance):
        self.balance = balance

Enter fullscreen mode Exit fullscreen mode

Objects created from this class:

  • Account A → 5000
  • Account B → 12000

Same structure, different state.


The Most Important Rule in OOD

A class should represent a single, meaningful responsibility.

When a class:

  • handles too many responsibilities → it becomes fragile
  • knows too much about unrelated domains → it becomes hard to maintain

Good design is not about size. It is about focus.


A Practical Design Flow

Before writing code, a structured approach helps:

  1. Understand the problem clearly
  2. Identify core entities
  3. Assign responsibilities to each entity
  4. Define interactions between entities
  5. Only then move to implementation

Skipping these steps leads to incorrect abstractions and redesign later.


Real Insight

In object-oriented design, correctness is not about syntax or patterns.

It is about:

  • clarity of responsibilities
  • consistency of state management
  • predictability of interactions

Good design is what remains stable when requirements change.


One-Line Takeaway

Object-oriented design begins when systems are modeled around responsibilities, not functions.