Yoda Conditions

April 25, 2015

Have you ever heard of Yoda Conditions? Maybe you saw some code written like this:

if ( true == $the_force ) {
    $victorious = you_will( $be );

I never really got why it could be useful to write a condition in that order until i found this part of the WordPress’s PHP Coding Standards:

In the above example, if you omit an equals sign (admit it, it happens even to the most seasoned of us), you’ll get a parse error, because you can’t assign to a constant like true. If the statement were the other way around ( $the_force = true ), the assignment would be perfectly valid, returning 1, causing the if statement to evaluate to true, and you could be chasing that bug for a while.

Now that makes a whole lot of sense, so make sure to write your conditions in that order from now on, even if it sounds strange at first. Or, as it is appropriately stated in the Coding Standards:

A little bizarre, it is, to read. Get used to it, you will.

PHP Coding Standards – Yoda Conditions

The Knife Maker

April 23, 2015

A shortfilm about a writer from Brooklyn who found his thing in handcrafted knife making. A very inspiring story!

In our second film, we meet writer turned knife maker Joel Bukiewicz of Cut Brooklyn. He talks about the human element of craft, and the potential for a skill to mature into an art. And in sharing his story, he alights on the real meaning of handmade—a movement whose riches are measured in people, not cash.

Made by Hand / No 2 The Knife Maker

Designing Settings by Imran Parvez

April 22, 2015

Imran Parvez wrote an interesting article on Medium about how to design a settings page. He covers some of the common mistakes and then some possible solutions with many references to the official design guidelines from Android and iOS.

Difficult product decisions should never become a setting. For example: If there’s a debate in your team which is building an email client, whether to show four lines of summary or two lines of summary for each email. Do not make it a setting!

Worth a read if you intend to design a settings page for your product.

Designing Settings

How to Center in CSS

April 20, 2015

Let’s be honest. Centering in CSS can really suck! At least without the use of flexbox. “How to Center in CSS” is a neat little page i found today which helps you choose the right way of centering for different situations (known/unknown width and height, inline or block element etc.) and generates some code to accomplish what you need.

While i like the general idea of this, there are some things that should be improved and that would make it a lot more useful. First, the generated code uses inline-styles, which is just a terrible thing to teach to anyone. Displaying the generated styles in CSS (or even SCSS & CSS) would be a lot better. Second, it would be nice if it would promote the use of flexbox, too. Third, as with most things there are different ways to accomplish the same thing, so a little bit of background information on each technique and why it’s favored over another would be really great.

If you need to center something in CSS and are unsure about which technique to use, then i would still recommend this post on CSS-Tricks. I look it up frequently when i need to center anything, but i could also imagine such a generator to become a really useful tool.

CSS-Tricks – Centering in CSS: A Complete Guide

Do not Track

April 19, 2015

Do Not Track is a personalized documentary series about privacy and the web economy. If you share data with the site, it’ll show you what the web knows about you.

Do Not Track