Skip to content

Latest commit

 

History

History
17 lines (9 loc) · 939 Bytes

Functions.md

File metadata and controls

17 lines (9 loc) · 939 Bytes

When writing functions, a few things need to be kept in mind:

Naming

Use verbs for naming your functions. Verbs, in English language, refer to names of actions. For example, jump, get, set, go, etc. are examples of verbs. This is a nice introduction to verbs from Khan Academy.

Coupling

Make sure the function is as little coupled with its environment as possible.

Purity

Write pure functions whenever possible. Avoid intertwining your logic and IO operations, so your logic remains testable and reusable.

Size

Do not create a function that is doing too many things. Keep functions small. A function should only do what it's name suggests. Same principle apply to classes as well.