Tuesday, September 26, 2017

Be a coder! Not really.

Recently saw this on the Twitters:

She really should have hired a better programmer to write that crap. Here's a couple problems:
  • Variable names. What the hell is PM? Why are your variable names in all caps? Variable names should be descriptive.
  • Declaring PM is unnecessary. It serves no purpose.
  • CODING is declared using the 'let' keyword, which in JavaScript means that the variable is declared using block scoping. For you non-programmers out there, that means that as soon as execution leaves the curly braces, the variable CODING is undefined.
  • The code does literally nothing. There are no side-effects. Again for the non programmers: the computer is the same before running this as it is after running it, and it produces no effects visible to the user.
Here's code that actually, you know, does something:

if (getQueryVariable("PM") === "signed") {
    alert("Coding 4 All");
} 

It uses a function defined elsewhere, but there are actual side effects of running this code, namely a popup message box.

Why am I being pedantic?


Does she genuinely care about getting more people involved in the industry? No idea. Does the ham-fisted approach come across as genuine? Nope. Pandering to kids who are excited about programming does nothing to actually engage them. You just end up looking like the old guy with his hat sideways.

No comments:

Post a Comment

All comments are moderated. I have a life, so it may take some time to show up. I reserve the right to delete any comment for any reason or no reason at all. Be nice. Racist, homophobic, transphobic, misogynist, or rude comments will get you banned.

Programmer vs Software Engineer: The Interview

A common question presented in interviews for developer positions goes something like this: Given an array of numbers, write a function th...