Key Programming Principles: KISS, DRY, YAGNI, and More
This article compiles essential software development principles such as KISS, DRY, YAGNI, Code for the Maintainer, and related guidelines, explaining their origins, practical applications, and why adhering to them leads to simpler, more maintainable, and higher‑quality code.
Programming principles help developers write simpler, more maintainable, and less error‑prone code. The following sections summarize the most frequently cited rules.
KISS (Keep It Simple Stupid)
KISS advocates keeping designs and implementations as simple as possible, avoiding unnecessary complexity. It originated from Lockheed engineer Kelly Johnson and is widely used in both hardware and software engineering.
Don’t Make Me Think – code should be easy to read.
Least Surprise – follow conventions and avoid surprising constructs.
DRY (Don’t Repeat Yourself)
DRY encourages a single authoritative representation for each piece of knowledge in a system, reducing duplication of code, documentation, data, and effort. Over‑applying DRY can harm cohesion, so balance is required.
Minimize repeated code, docs, data, and effort.
Prefer reusable libraries over reinventing wheels.
Automate repetitive tasks where possible.
Avoid excessive optimization that breaks cohesion.
YAGNI – You Ain’t Gonna Need It
YAGNI advises implementing features only when they are truly needed, preventing wasted time and resources. It leads to less code to maintain, test, and refactor, and frees time for more valuable work.
Less code maintenance.
Less testing effort.
Easier refactoring when requirements change.
More time for important features and documentation.
Code For The Maintainer
Write code that is self‑explanatory and easy for future maintainers to understand, remembering that someone else (or you later) will need to work with it.
Be as lazy as possible.
Embrace laziness by reusing existing solutions, avoiding reinventing wheels, and not over‑optimizing; this drives progress by focusing effort where it truly adds value.
Programming is only the road, not the way
Coding is a means to solve problems, not the end goal. Understanding the problem domain and when not to code is essential for effective software development.
If you are in a hurry, stroll along slowly. If you really are in a hurry, make a detour.
Take time to ensure correctness; rushing can lead to compromises that cause later issues.
Know your path, Neo.
Familiarize yourself with the development environment, tools, and dependencies, and only introduce new components when fully understood.
If it wasn’t tested, it is broken.
Untested code is unreliable; thorough testing is a prerequisite for confidence in software.
Distinguish cause and effect in code, fact and opinion in conversation
Apply additional design rules such as minimizing coupling, maximizing cohesion, the Open/Closed principle, Single Responsibility, hiding implementation details, and the Law of Demeter.
Original source: What do you consider the 1st principle(s) of programming? Reference links: Do The Simplest Thing That Could Possibly Work (http://c2.com/xp/DoTheSimplestThingThatCouldPossiblyWork.html), Code For The Maintainer (http://wiki.c2.com/?CodeForTheMaintainer), etc.
Architects' Tech Alliance
Sharing project experiences, insights into cutting-edge architectures, focusing on cloud computing, microservices, big data, hyper-convergence, storage, data protection, artificial intelligence, industry practices and solutions.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.