Why

Methods allow us to make our code shorter, more readable, and more maintainable.

Shorter - We don't have to rewrite the same lines of code over and over again. Instead, we put that code in a method, and call the method.

More Readable - Code divided into small units of work (methods) is easier to read. We give each method a name that describe the tasks it performs.

More Maintainable - Each method can be tested and modified independently. If we don't repeat code, and instead call a method, changing it in one place changes it throughout the code.


Prev -- Up -- Next