Fundamentals 10 min read

Common Software Design Principles: DRY, KISS, SOLID, and More

This article summarizes key software design principles such as DRY, KISS, SOLID, New Jersey style, Separation of Concerns, and YAGNI, explaining their meanings, benefits, and practical code examples for writing cleaner, more maintainable code.

Architecture Digest
Architecture Digest
Architecture Digest
Common Software Design Principles: DRY, KISS, SOLID, and More

Introduction: The article summarizes several widely used software design principles and informal rules based on the author's experience.

DRY

DRY stands for "Do Not Repeat Yourself". The strict definition is that every piece of knowledge must have a single, unambiguous, authoritative representation within a system. In practice it means avoiding duplicated code; instead extract repeated logic into a helper method.

html = html.replaceAll("\\<.*?\\>","") 
html = html.replaceAll(" ","");
html = html.replaceAll("&"," ");

If the same code appears in hundreds of places, a change would require editing each occurrence. Therefore the DRY rule recommends encapsulating the logic in a method.

Related concepts include DIE (Duplication is Evil), SPoT (Single Point of Truth), and SSOT (Single Source of Truth). The opposite of DRY is WET ("write everything twice" or "we enjoy typing").

KISS

KISS means "Keep it simple, stupid" (or "Keep it short and simple"). It encourages simple, understandable designs.

Benefits of KISS include faster problem solving, less code for complex problems, higher code quality, easier operations, better extensibility, and more flexible code.

Practical suggestions: avoid relying on comments for readability; write clear code. Example of a poor variable comment and a better alternative are shown.

// i is for 'counter' and j means total sumint i, j;
// more intuitive oneint counter,sum;

The principle aligns with Occam's razor: the simplest solution is usually the best.

New Jersey style (Worse is better)

This principle states that a system's quality does not necessarily improve with more features; a simple, usable tool can be preferable to a feature‑rich but cumbersome one (e.g., vi/vim, Chrome).

SOLID

SOLID is an acronym for five object‑oriented design principles.

Single Responsibility Principle (SRP)

A class should have only one reason to change, meaning it should encapsulate a single responsibility.

Open/Closed Principle (OCP)

Software entities should be open for extension but closed for modification; new behavior is added via new classes or methods rather than altering existing code.

Liskov Substitution Principle (LSP)

Derived classes must be substitutable for their base classes without altering the correctness of the program.

Interface Segregation Principle (ISP)

Clients should not be forced to depend on interfaces they do not use; fine‑grained, client‑specific interfaces reduce coupling.

Dependency Inversion Principle (DIP)

High‑level modules should depend on abstractions, not concrete implementations; abstractions should not depend on details, mirroring the Adapter pattern.

Separation of Concerns (SOC)

Separating different concerns reduces complexity and is similar to SRP in SOLID.

YAGNI

YAGNI stands for "You Aren't Gonna Need It". It advises against implementing functionality until it is actually required.

References

DRY

Six Design Principles – Liskov Substitution Principle

SOLID

How to keep code simple

Occam's razor

Apache KISS

Worse is better

software architecturedesign principlesDRYSOLIDKISS
Architecture Digest
Written by

Architecture Digest

Focusing on Java backend development, covering application architecture from top-tier internet companies (high availability, high performance, high stability), big data, machine learning, Java architecture, and other popular fields.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.