Break programs into reusable subroutines with parameters, returned values and clear scope.
Put a named task into a reusable subroutine and call it when it is needed.
Calculate a value inside a function, return it and store it in the caller.
Understand where a variable exists and choose parameters over unnecessary global state.
Process a collection inside a sub-program without relying on global data.