Skip to content

When to create a separate function?

Mikhail Panko edited this page Aug 26, 2013 · 1 revision
  • Make each function solve only one meaningful self-contained task
  • Separate code that is repeated at least once into its own function; if the code is repeated with small variations make it into a function with parameters
  • Cap function length at around 100 lines of code (less than 1 screen length is even better)
Clone this wiki locally