software-design/functions-why-you-should-stop-copy-pasting-your-code.md

Functions: Why You Should Stop Copy-Pasting Your Code

Building software · 9 min read ·

Copy-pasting code works fine on the day you do it. It fails the day you need to change it, and have to find and fix every copy without missing one.

A function fixes that: write the code once, give it a name, and call it as often as you like. This page shows how values go in (parameters and arguments), how they come out (return, and why print is not the same thing), and why programmers live by DRY: Don't Repeat Yourself.