Clean code
  • Overview
    • Introduction
    • Why is clean code so important?
    • What Is Clean Code?
    • How to write clean code?
    • Conventions
  • The key principles of clean code
    • Meaningful Names
    • Functions
    • Classes
    • Comments
    • Error Handling
      • Exception handling best practices
    • Unit Tests
    • Formatting
    • Objects and Data Structures
    • Simple Design Rules
    • Concurrency
    • Code Smells
  • Building Maintainable Software
    • Write Short Units of Code
    • Write Simple Units of Code
    • Write Code Once
    • Keep Unit Interfaces Small
    • Write Clean Code
    • Automate Tests
  • Bonus
    • SOLID Principle
      • SRP - Single Responsibility Principle
      • OCP - Open-Closed Principle
      • LSP - Liskov Substitution Principle
      • ISP - Interface Segregation Principle
      • DIP - Dependency Inversion Principle
    • LoD Principle
    • YAGNI Principle
    • DRY Principle
    • Fail Fast principle
    • Hollywood Principle
    • Library vs Framework
    • Coupling and Cohesion
    • AOP - Aspect-Oriented Programming
      • Building an AOP framework
    • OOP Design Pattern
    • Technical Dept
    • How to learn software Design and Architecture - Roadmap
    • Microservcies
      • Defining the scope of a microservice
      • Step-by-Step: How to Identify Over-Scoped Microservices
      • Benefits of Grouping or Consolidating Microservices
      • A practical step-by-step plan to consolidate microservice
Powered by GitBook
On this page
  1. Bonus

YAGNI Principle

You aren't gonna need it

A design principle from Extreme Programming (XP) states that a programmer shouldn't add any functionality until it's actually necessary.

Ron Jeffries, one of the founders of XP wrote that programmers should "always implement things when you actually need them, never when you foresee that you need them" and "do the simplest possible thing that will work".

Why is it useful?

  • This can help you iterate really quickly.

  • It helps prevent design fatigue or fear of a large all-encompassing up-front design.

But!

YAGNI is meant to be combined with continuous refactoring, automated unit testing, and continuous integration.

Failure to refactor code early could require huge amounts of technical debt and rework.

Therefore, in order to do YAGNI well, developers first need to know how to:

  • write code that's testable

  • run automated tests

PreviousLoD PrincipleNextDRY Principle

Last updated 2 years ago