Skip to content

Latest commit

 

History

History
24 lines (17 loc) · 614 Bytes

File metadata and controls

24 lines (17 loc) · 614 Bytes

DRY

DRY stands for Don’t Repeat Yourself. It avoid code duplication, eliminate redundancy in code and processes.

Bad Example

def calculate_area_of_rectangle(length, width):
    return length * width


def calculate_area_of_square(side):
    return side * side

Good Example

def calculate_area(length, width):
    return length * width

Repeating the same code or logic in multiple places leads to maintenance nightmares. Instead, centralize common functionality to a single location.

Interesting Article on DRY