Fork me on Github
Fork me on Github

Joe Dog Software

Proudly serving the Internets since 1999

up arrow Please Don’t Use Comments To Alter Functionality

“Holy shit!” Your JoeDog exclaimed.

“Why do you swear so much?” an emailer emailed this blog. “Young readers don’t need to be exposed to that.” Listen, if your kid is reading this site, then maybe it’s time to buy him a football. By the time he’s old enough to care about these topics, he’s already heard a lot of vulgar language….

“Holy shit!” Your JoeDog exclaimed. “That’s a code salad!”

Our enterprise backup guy is just like your enterprise backup guy. He’s involved with every system, every project and every meeting yet all he does is put ones and zeros on tape. Generally he calls your attention to meaningless minutia but once a decade you learn of something important. Yesterday was once a decade. Backup informed Your JoeDog that the NetBackup client wasn’t installed on a new server.

“That seems unlikely,” Your JoeDog said. “Puppet puts it on every server.” Puppet is our configuration management server. It installs software and writes configurations to every server in the enterprise.

“That’s what I thought,” Backup said. “But it’s not there.”

To prove that Puppet puts it on every server, Your JoeDog showed him the code. We’ll examine that code after the jump

class nbu::install {
 if $operatingsystemrelease >= 6 {
   package { "glibc.i686":
     name => "glibc.i686",
     ensure => present
   }
   package { "libacl.i686":
     name => "libacl.i686",
     ensure => present
   }
   #package { "libstdc++.i686":
   #name => "libstdc++.i686",
   #ensure => present
   #}
   package { "elfutils-libelf.i686":
     name => "elfutils-libelf.i686",
     ensure => present
   }
## nbu::install commented out since upgrade
## to 7.5.0.7
# package { "nbu-armstrong":
# name => "nbu-common",
# ensure => present
# }
 }
# else {
# package { "nbu-armstrong":
# name => "nbu-common",
# ensure => present
# }
# }
}

At some point the Pope is gonna google this and when he does, he’s gonna say “Holy shit!”, too.

Believe it or not, that class wasn’t written by a summer intern or a homicidal psychopath. It was written by an IT professional.

First of all, it uses comment operators to alter functionality. This code is under version control. If you don’t want something, take it the fsck out. If you want to roll it back, use god damn version control. (That’s a lot of vulgar for a mommy blog).

Second of all, WTF?  if condition install_software else install_software;  Did I mention this was coded by an IT Professional?  

For those who don’t care for Your JoeDog’s naughty words, here’s how you can personally reduce the amount naughties he lets rip: Refine your logic and don’t use comments to alter functionality. That is all.