Tag: Functions

Readable Functions: Guard Clause

Guard Clauses are one of my favorite little tricks that allow simplifying code. A guard clauses is an if statement with a return in it. Consider the following code:

Using a Guard Clause we can simplify it …

Readable Functions: Do One Thing

Several tricks and heuristics that I apply to write easy to understand functions keep coming up when I look at other people their code. This post outlines the second key principle. The first principle is Minimize State. Following …

Readable Functions: Minimize State

Several tricks and heuristics that I apply to write easy to understand functions keep coming up when I look at other peoples code. In this post I share the first of two key principles to writing readable functions. …

Missing in PHP7: Named parameters

This is the second post in my Missing in PHP7 series. The previous one is about function references. Readability of code is very important, and this is most certainly not readable:

You can make some guesses, and in a …

Missing in PHP7: function references

This is the first post in my Missing in PHP7 series. Over time, PHP has improved its capabilities with regards to functions. As of PHP 5.3 you can create anonymous functions and as of 5.4 you can use the …

Clean functions

Last week I gave a presentation titled “Clean functions” to my Wikidata colleagues. As the title suggests, this presentation is all about how to create clean functions that are easy to understand and modify. Why did I go …