zaro

What is KISS dry?

Published in Software Principles 2 mins read

KISS, in the context of software development principles, actually stands for Keep It Simple, Stupid; it is not about being 'kiss dry'. The principle is one that focuses on simplicity, but it's often paired with another principle, DRY (Don't Repeat Yourself). The reference provided does not discuss "kiss dry." It clarifies the meaning of both DRY and KISS as common software engineering principles.

Understanding KISS and DRY

Principle Meaning Goal
KISS Keep It Simple, Stupid Design systems that are easy to understand and maintain. Avoid unnecessary complexity.
DRY Don't Repeat Yourself Reduce code duplication to make code more manageable, efficient, and less error-prone.

KISS in Detail

  • Simplicity First: Prioritize straightforward solutions over intricate ones.
  • Reduced Complexity: Avoid adding extra features or code unless they are absolutely needed.
  • Easier Maintenance: Simple code is typically easier to read, understand, and debug, leading to reduced maintenance time.

DRY in Detail

  • Code Reusability: Write code that can be used in multiple places without needing to copy and paste it.
  • Reduced Redundancy: Eliminate identical sections of code. This could involve functions, classes, or modules.
  • Consistency: DRY helps ensure consistency because updates are only needed in one location.

How KISS and DRY Work Together

While they are separate concepts, they complement each other.

  • Following DRY can lead to more complex solutions if not careful.
  • KISS serves as a check to help ensure that while eliminating repetition you don’t unnecessarily over-complicate your solution.
  • Ideally, one follows both principles to create code that is maintainable, efficient, and easy to comprehend.

Practical Examples

  • DRY:
    • Instead of copy-pasting code to calculate the area of a rectangle multiple times, create a function that performs the calculation. This function can then be called from various locations, adhering to DRY.
  • KISS:
    • When faced with the choice of implementing a complicated sorting algorithm or using a built-in one, KISS suggests you should often choose the built-in method.
    • Avoid overly complex classes and use simple data structures.
  • Combining both principles
    • Create a basic function to perform a common task and use it in all appropriate cases rather than rewriting the same logic. This ensures DRY without overcomplicating your code, adhering to KISS.

In short, KISS is about simplicity; there's no concept of "kiss dry." DRY, on the other hand, means avoiding code repetition. Both principles help in creating better software.