

It's explained in more detail in this video. It's a principle where you design your types over what they do instead of over what they are. YAGNI should be used in conjunction with continuous refactoring, unit testing, and integration.Ĭomposition over inheritance: Not an acronym, sadly. YAGNI is part of the Extreme Programming (XP) methodology, which wants to improve software quality and increase responsiveness to customer requirements.

A developer should not add functionality unless deemed necessary. Violations of DRY are referred to as WET: We Enjoy Typing, Write Everything Twice, Waste Everyone's Time. It states that every piece of knowledge (code, in this case) must have a single, unambiguous, authoritative representation within a system (codebase). Closely related to KISS and the minimalist design philosophy. The question to ask when you're writing code is "can this be written in a simpler way?"ĭRY: Don't Repeat Yourself. Unnecessary complexity should be avoided. It states that most systems should be kept as simple as possible (but not simpler, as Einstein would have said). A design principle originating from the U.S. As such, even though the initial question on our Slack channel was about how to keep your JavaScript / TypeScript code clean, X-Teamers replied with some of the general design principles of clean code. Instead, it relies on language-agnostic principles agreed upon by the developer community. Clean Code PrinciplesĬlean code doesn't rely on language-specific rules. Recently, X-Teamers discussed their most important principles to keep their code clean, and we decided to share the best ones with the world. No one writes clean code from the beginning. While it might take longer to write clean code in the short term, it's beyond established that writing clean code will save everyone time, effort, and ultimately money.īut there's always room to learn. Bad code is difficult to understand, more complex than it should be, not easy to test, and it makes other developers seethe with frustration. Bad code works until it's the year 2,000.
