Lollipop Code

Back in 2004, Demetri Martin had a funny bit about lollipops:

A lot of people like lollipops—I don't like lollipops, 'cause to me a lollipop is: hard candy plus garbage.

I don't need a handle. Just gimme the candy.

I've thought of that sketch many times in the dozen years since it aired. In particular I think of it when I see code that's repeatedly redundant.

I've taken to calling such code "Lollipop Code", because it's code plus garbage.

Here are some examples of lollipop code:

<div id="divWidget">
if (value == true) {...}
$(...).on(function () {
var show = control == null ? false : true;
padding: 5px 10px 5px 10px;

In many cases, lollipop code can be fixed by applying static code analysis to remove redundancies. However, there are many cases where static code analysis can never suggest improvements.

Hungarian notation is a classic example, where code analysis won't be able to make an informed decision about a bad naming convetion.

Don't get me wrong, naming things is hard, so be sure to invest time into refactoring and revising code after it's written.