• tofuwabohu@lemmy.161.social
    link
    fedilink
    arrow-up
    3
    ·
    3 years ago

    You use functions to extract code that does a specific thing to encapsulate it. So when you want to do a specific thing at three different places in your program, you don’t need to write the same code three times but you call the function. It avoids redundancy and this is easier to maintain (only one place to fix stuff).