Pure Functions
I love pure functions. They always return the same output for the same input, and they don’t have any side effects. Wrap them in another function that logs the input and output (as long as these have simple types) and it can generate tests just by running your application, and you’ll only have to check the tests instead of writing them.
In my mind, the opposite of a pure function is a controller action in an application server. Should we call them impure functions? Immoral? Applied? Dirty? I prefer to call them practical functions. They can access anything - access the database, the file system, the network, make arbitrary api requests. Practical functions can do it all. I love practical functions.
What should you do next?
Read my articles. View my resume. Connect via email. Visit my GitHub account.. Follow the site using RSS.