How to suck at programming #FEFE23 donate your day to a bug

It’s a holiday, everyone is partying but you got better things to do. Up early in the morning, you power on your vehicle and head to the office like the model employee you know you are. The wife queries, “Isn’t it a holiday?” to which you mumble, “I gotz deadlinez!” The looming release date of the project you’ve been working on for the past couple of months is beginning to weigh on you like last Thanksgiving’s turkey and yams. Hi, I’m Cliff. You’re here because you suck at time management. On with our story… The air around your shoulders now feels like lead and you can almost make out the text of the actual delivery date as you watch its molecules adhere to one another with each passing hour. Today will be different! You have the entire office to yourself and you will be Mr. Super Productive Programmer Guy ready to close out the 12 top Jira items in 1 heroic effort!

You arrive bright and early, and only dabble on Social media for an hour because, “hey, it’s the holiday and you gotta have some enjoyment!” Finally dismissing further distractions you power up your IDE and go to work! You finally restore the memories tucked away in the soft tissue inside your skull which originated last Friday when you came up with the terrific idea to finish your work over the holiday. “Yes, this is the issue I needed to resolve!”, you verbalize audibly knowing that nobody is in the office to witness your late morning schizophrenia.20 minutes into your effort you hit a snag which sends you off in a whirlwind of meta-problem resolution, also known as yak-shaving. Undeterred you press on, confident because you weird the most powerful IDE on the planet and no amount of yak hair will keep you from making your deadline.

Finally it bites you. The one bug that makes absolutely no sense because the source code was working entirely different just prior to your recent changes. The changes you introduced are the absolute logical equivalent of the original version of the source code. There is no way in the world the behavior should be altered. You have made what is the textbook definition of a safe refactoring yet things have dramatically stopped working! You refuse to use your debugger because everything is TDD on this project. Unit test failure after unit test failure eventually causes you to break down and add log statements, then finally use the debugger. The debugging session leaves you even more puzzled as you Google random log output and red-herring type error codes. You glance briefly out the window and the sun has grown several shades darker and you start to feel your heroic day slip into night. Hour after hour leaves you more stranded, frustrated, and confused as you throw different possible solutions into your IDE, practically reauthorizing the entire project along the way. The emulator that your app runs on mocks you with scorn, the internet feels like its laughing at your pain, you have no other recourse but to throw in the towel but you refuse to give up.

Finally you begin a round of rubber-duck (or teddy bear) debugging speaking aloud each line of source code as you step through your logic mentally. Three minutes into the ducky-debugging it becomes painfully obvious where the problem is originating! The most obvious oversight of a relative URL which should have been absolute! How could you be so blind? Why did you go through all the chaos of rewriting your entire project??? 7 extra characters is all it takes to make the original version of your modifications green bar!

Alas, the day is old and the curtain call has begun on your life as the credits begin to roll announcing the tail end of your holiday. You look at your progress and realize that you have fixed one minor insignificant bug in an area of the app that only you and the night time janitor know exists. (The janitor only know because you spend nights discussing your problems and have been stuck on this issue for months.) Hooray for you! You have devoted your entire holiday towards fixing the only feature in the entire app that does’t actually get used anymore. So if you wanna suck at programming, skip a holiday, go to work, and obsess over that one unused feature. You’ll learn more about the edge cases of the web browser in your emulator and never live to appreciate those precious 24 hours again in your life.

How to suck at programming #441

You’re outside on a sunny day tethered to your mobile phone hotspot and limited data plan writing code using an editor that isn’t your main tool. Maybe you’re an Eclipse die-hard or maybe you live on Xcode for your day job. Whatever the case, you find yourself in something like a SublimeText, Notepad++, or TextMate for something you are prototyping. You’re mostly familiar with the hotkeys but again this is not your day job editor so you’re prone to get one or two of the sequences from your main tool mixed in on occasion. You go to quickly comment out a section of code when muscle memory kicks in and the next keystrokes invoke Ruby integration. Hi, I’m Cliff. You’re here because your Macbook is currently downloading an unknown Ruby package (or packages) over a limited mobile carrier connection and you won’t know how much is left in your monthly allotment until you finish reading this article. I’m here to share a similar experience that just happened moments prior to my writing.

Welcome to my How to suck at programming series. There’s no particular reason why I’d been listing these tips in random order, however feel free to peruse what I’d posted in the past if you really enjoy the merits of being an awful programmer. I write todays post with hesitation because I’ve been going through a low point in my career and I have been doubting my abilities. Still, this is a must-post topic and I enjoy making others feel enlightened on how to be dumber than usual.

So what happens when the stars align in a perfect arrangement capable of ruining your day/week/month? What do you do when you’ve accidentally invoked an unknown feature in a tool that you only use on occasion? What do you do when that tool spawns an unknown external process designed to gulp down potential gigabytes of data over a limited mobile data connection? Why do we even have limits on our mobile data connections??? (Curse you AT&T!!! I condemn you and your penalties per excess gigabyte!!!) Don’t they have something way better overseas?

My story actually begins in a hospital building somewhere in Mt. Holly N.J. where I shed my first tears but I’ll spare you the extra drama including the part where I finally realized I was too old to still try to bring toys to school (6th grade) and give you the abbreviated version… that is, if you’re still interested.

So there I was stuck in an unanticipated initialization sequence spawned from TextMate. “Initializing Ruby 1.8” is what the pop up window said. It was scary. Mostly because I wasn’t sure what “initializing Ruby 1.8” meant, but partly because there wasn’t a functional close/cancel button on the popup window. I know most Ruby programs usually use Ruby Gems. I know Ruby gems can be a separate download/install and I know that Ruby Gems can potentially download other Gems. I didn’t know if any of this would be part of the initialization.

What was this mean initialization dialog doing to my Mac? What was it doing to my data cap??? What was I doing downloading Ruby??? In an extreme exercise of yak-shaving, I set out to teach my daughter some more Javascript stuff. The lesson ended with my trying to recode Khan academy’s interactive design page in roughly 20 lines of vanilla Javascript because, you know, I thought it’d be cool to show her how things worked on the page where she learned to draw a turkey dinner with the line, ellipse, and image functions.

My reasoning went something like, “I’ll teach her this cool trick and ignore the fact that there is multiple layers of indirection involved. Afterwards she’ll realize how cool the code and her Dad is then we’ll finish the project this week and sell the product to eBay for $500m!” This is because everyone who is anyone knows to sell a Javascript side-project to companies like eBay, it’s just common sense. At any rate, I’m failing at recreating Khan academy, failing as a super programmer, and failing as a father when I realize my daughter has lost all interest in the twist of logic I tried to confidently demonstrate. I also realize she has to leave for a sleepover. Undeterred in my efforts as a script ninja I took my operation to the Cupertino Library where I could concentrate sans distractions.

I finally succeed at hacking together something horrible looking enough to pass as a Frankenstein Khorn-Alch-tradgedy. Proud of my tardy solution, I test it a few times while mumbling how simple the source code behind the more professional Javascript editor should actually be. Who needs You-Tube interactive voice coaching anywayz? This is when I decide to simplify my logic and comment out a few lines of code triggering the unknown consequences of a Ruby initialization.
So if you want to suck at programming, teach your child Javascript. Then get sidetracked on a complicated unrelated demonstration of irrelevance while persisting until you can actually smell your child’s lack of confidence and trust in the air. Ignore all signs of boredom from the little one and continue until they roll credits between you and your keyboard.

How to Suck At Programming #739

Quickly create a patch for a single file edit using “svn diff” and then review the word wrapped command line noticing you forgot the file redirect operator “>” in the command so let’s put it in the first blank spot your eyes detect after the word “diff”…

svn diff my/complicated/path/to/the
/single/file.m > my-last-minute.patch


svn diff > my/complicated/path/to/the
/single/file.m > my-last-minute.patch

How To Suck At Programming #392: Type your password into your AIM window

You’re on AIM blast. You’re having fun with your buddies, talking tech and shooting the breeze. You pack up to leave work early and run some errands. Just before signing off you can’t resist cracking one more dumb joke. “…and that’s why Budweiser employees don’t use Java!”, goes your reply to one of your AIM buddies. That triggers to one more round about Hibernate, Anheisuer Busch, and the stock market. Yes those are three topics that are totally unrelated but you don’t care. You tied them together in your twisted programmer humor-logic and made a funny. Good for you! Glancing at the clock in your Windows taskbar you notice you’re already ten minutes late! Windows Key+L locks your machine and you storm out of the building.

Arriving home after running back and forth across town to pick up odd items for your daughter’s 5th grade project, you have a chuckle at Judge Judy as she embarasses the plantiff just before awarding her the maximum amount of $5,000. That loosely reminds you of the last couple of tasks you neglected to finish before running home for the day. After firing up RDC (Remote Desktop Connection) on your Mac, you’re quickly greeted by the Windows desktop log in dialog to which your fingers instinctively dance over the letters spelling out your password. (This is, of course, the same password that you use for all of your online banking, bill payment, blogs, Twitter, and Facebook accounts.) A breif pause and the AIM outgoing message chimes. “That was unexpected!”, you mumble quietly in your skull. Your brain slowly pieces together the chain of events and colors the truth behind the chime. You weren’t sitting at your desk even though the Windows screen fooled your brain into believing you were. You were working remotely using RDC, a nifty program that can actually cache your log in password saving you the 8-12 characters that you’re too lazy to type if you don’t have to. You muscle memory just exposed your one-size-fits-all password to all of your buddies on the AIM blast that you never signed out of. Good job. You just saved over 8 key presses at the expense of the 80,000+ it will take to reset all of your accounts, explain the finger fumble to the blast group and more.

So if you wanna suck at programming, type your password into your IM window. Not only will you expose your darker secret Flickr account to all, you will have a lifetime of sleepless nights wondering “did I ever reset my other other email account?”

How not to link a framework in iPhone dev

With much help from Erik, the owner of OCMock, I discovered how much of a loon I can be. Let me set the stage with a story, like I typically do on this site. You’re writing unit tests for a spankin’ new iPhone project that’s gonna shake the world if it ever releases. You’ve got backing suport from everybody from MGM Studios to Barack Obama helping you to make your release date. You are an advocate of all things Agile, TDD, and behavior driven. You absolutely cannot fail! You now need to do something clever in your unit tests. Something Apple doesn’t provide facilities for. You find a framework that does it. Maybe you’re bringing in OCMock or maybe you’re just trying to link Hamcrest. Hi, I’m Cliff. You’re here because your framework won’t load in your unit tests. I’m here to tell you how not to link against it.

Many years ago (like 1), I tried to link against OCMock. The only way to make it work was to drop it into the magic place called “/Library/Frameworks/”. It worked. It worked well. It worked so well that I decided to become the OCMock super hero. I wrote a blog about it. (Like to hear it? Here it go!) I wrote an OCMock setup thing with Automator/AppleScript for other developers that weren’t as John Blazed as I was so that they too could enjoy the beauty that was OCMock. (Just had a flashback to the little stored procedure runner tool I wrote when I was being the VB6-toRPGIV super hero many more years ago.) Here’s where a super hero becomes a super zero.

I neglected the principles of software development. Anything that goes in a System folder is visible to everything. Putting files, tools, trinkets there are always error prone, remedies for disaster. Why? Because it’s fire and forget… A one time setup that you never need to worry about. The forget part of the fire is what bites. The one time step that you always need to think about when troubleshooting but never do. Like I said, a year passes and I haven’t done much with OCMock except for occasions. Now I wanna upgrade to the latest version. I’ve since learned a better way to link projects to frameworks but my machine still “remembers” the old way. My new process, from memory, goes something like:

  • Find a framework
  • Drag/drop it into your project
  • Do something in the build configs, like setting a framework search path
  • I think that’s it, right? Yeah. Compile and run and I see the green button. I’m good!

Everything works as expected. I’m pretty sure I’m picking up the right version because I just double clicked the little framework icon and triple checked the path pointing to the newly downloaded folder. I could go the extra mile and look for the notes I wrote last year and make sure there’s no other gotcha’s but things are working. Why bother?

There’s two critical problems here. the first is that I never removed the frameworks from the magic “fire and forget” place. Just don’t put things here and you’ll never have to remember to delete them when you upgrade or when they break other things. The second problem is that I didn’t remember my new method for linking because my machine still remembered the old way making me feel like I was all good. The better way to link frameworks in iPhone dev is to put a “copy files” build phase into your target, set the destination path to “products directory” and drag/drop your frameworks into this phase. One caution is that while you can run on the Mac using the Simulator you still can’t load frameworks on the device. So I conclude this long winded article that could have been summarized in 2-3 sentences by saying, if you wanna suck at programming overload your system folders with development frameworks and libraries. Not only will you immediately solve the problem at hand and meet your immediate deadline but you’ll break the next twelve identical problems in the future and miss all of those deadlines. Good luck making up weeks of productivity lost chasing a problem that only exists on your machine. Good luck making up several more weeks of lost productivity while you reinstall your OS and lose several other important files/temporary projects trying to fix the problem that only happens on your machine.

HTSAP #473 Thief in the night

It’s 11pm. I’ve pretended to weight train in the basement for about an hour. My wife’s out of town. The kids have had dinner and are off to bed. I’ve killed twenty minutes or so fooling with YouTube and misc web articles and I’m now off in a development zone. The world disappears around me. Nothing exists except for the keyboard the Mac touch pad and my IDE.

Out of the blue my “Spidey Senses” grab hold of me to alert of an in-home intruder but it’s waay too late! Sneaking up from behind, I turn around to learn that the intruder is already on top of me. My heart drops, muscles lock. My internals drowned with adrenaline, I wanna leap up to defend myself but that would be unnecessary. This intruder is less than my shoulder height when sitting. Besides, my frozen, fatigued muscles leave me helpless in my seat while my brain trails to keep up with the action.

The body is way ahead of the brain as it already sees its death from the would-be 3 1/2 foot assailant. The internal organs have already moved from shock to shit stains while my grey matter performs what feels like a SQL Server deep index algorithm in the foreground. Using all the random pictures that my single threaded mental process could gather, I try to piece together pixel by pixel inside the unknown silhouette. I begin to feel a sense of familiarity with the figure. Still my body is stuck in fight or flight mode. Two mickey mouse circular shapes load up first as my linear search answers a series of sequential questions. “Mickey Mouse? No! Jerry, from Tom and Jerry? Not at 11pm! Chucky Cheese? Uh-uh!” Now its been 2 seconds that feel like 8 hours and my brain is convinced it knows the invader while my left arm is ready to throw a punch at the soon-to-be victim. “…Must …continue round 12 of Pictionary!” urges the sponge in my head. “Must… swing with full force”, my body fights back in disagreement.

As second three ticks away I’m finally able to defrag enough raw material in my skull to make out the picture of my 5 year old daughter who is now witnessing Daddy have a seizure. I fight to rescind the attack order from my left arm and replace with a hug order given to both arms. It’s too late. The damage is done. What could have been a warm greeting from daughter to Daddy has turned into the trail of tears as the adorable nighttime hoodlum weeps and informs she needs to go potty. Of course my under reaction to her presence disappoints as she obviously wanted to square up in a death match. I send her crying to the toilet while a sea of angry relief washes over me. If you wanna suck at programming have kids. Not only will you miss the opportunity to fix the double screen-drawing bug that will take the better part of the following day, but you’ll have lots of fun explaining… from the emergency room… to your spouse why your youngest child asked, no begged for an uppercut to the jaw.

(No children were harmed during or prior-to the writing of this post. However the author reserves the right to jab, kick, stab, and/or shoot random figures that suddenly appear within arm’s reach after 10pm regardless of age, height, stature, gender, or religious background.)

How To Suck At Programming #678- Fat Fumbly Fingers

So you have a bajillion plugins installed in each of your forty seven thousand desktop apps you use regularly. You’ve trained yourself to use 95% of the features in all of them. There isn’t a task you can’t accomplish without a hot-key or a muse gesture. Entire applications are built with a few mashes of Alt+Enter, F2, Ctrl+Alt+M combos. your machine can incrementally visualize the matches of a regex as you fill in character by character the complicated syntax and you’ve used that to sweep 30,000+ file source repositories in a global search replace refactoring. You’ve learned to link your SQL editor using crazy UDFs and plugins to an LDAP server across the planet in India to make remote SSH requests back to a laptop in California that runs WebDAV commands to the subversion repo sitting one desk away from you. Deploying software has become a pleasure as you merely drag/drop files from one ultra secure mounted file-share to another. Literally everything in your life from your finances to your vacation schedule, to your grocery list is managed by some macro, cron job, or automated script. Your email is accessible from either of your two mobile devices and is linked to your IM which is tethered to your twitter account. (Hot keys from the desktop allow you to add/remove/link social networking accounts at a whim.) You’ve become the emperor of your domain, the man at IT.

You occasionally watch, giggling inside, as others struggle to recall the proper remote commands to sequence together in order to perform daily work. You wince in pain as you help co-workers who struggle with the mouse to navigate the copy/paste commands. You shake your head in disapproval at a guy that’s sooo proud of an application he worked on for four months that does the same thing as the open source plugin you installed last year. Confidence is your first and last name. (It’s also the name you gave to your two kids, the family cat and the squirrel that visits your deck in the morning.)

Your manager hands you an assignment while three other co-workers pester you with random questions. “Where is the latest revision of the proxy servlet that Tim worked on?”, “Who was the first person to commit and break this mornings build?”, “How many more weeks of work remains before our deadline?” You’ve handled all this before and then some. All in a days work! As you execute commands in your terminal running on one monitor you bring up your browser in another to check the build server. You’ve also clicked the doo-hickey in your IDE (the one that scours Subversion with the regular expression auto generated from your other plugin) before sending that window to the background. Open up the email client now so you can immediately send an office wide letter claiming success on the 14 tasks that are now in progress. Wait a second! The hot key combo didn’t bring up your mail editor pre-filled with the company logo, and template text (and funny random fortune teller quote at the footer) like it always does!!! WTF? A few repeats of the hot key followed by some other memorized combos you perform on instinct when things go wrong. Crap!!! As you stare at the title bar of an inactive email client it becomes evident that your key presses were being sent to the active IDE you thought you sent to the background. Panic sets in as you try to recall which part of the hot key assault activated which actions in the IDE. There’s just soo many! There’s no time to think as a progress bar counts down in the window indicating some sort of delete task. It must have been a finger slip that leaned too heavily on the tab key in one of your earlier keyboard gymnastics. That would have caused the IDE to come back to the front but at which point???!! Was it Cmd+Alt+A? Or was it the Alt+Shift+Q? Oh dang! Didn’t you switch the F2 key to toggle windows last week when you read that article in MacInsight? Forget about it! You gotta find out which part of that secure server your IDE is chewing on is losing its data!

As you pray on the admin team to not have forgotten daily backups last night you frantically page through windows trying to kill the hidden process that didn’t die when you closed the guilty hot-key-eating application. Great job genius! You’ve managed to find the hot-key combo of death in you futile attempts to make your twenty different devices manage themselves. While trying to revert back to the more careful mouse driven approach of moving the twenty incoming messages from your inbox to your important folder you’ve also managed to drag from your email drafts folder to the outgoing folder exposing all of the half written in anger messages you never intended to send to upper management. If you wanna suck at programming, practice automation and hot-key memorization to the extreme. You’ll have to touch you keyboard and mouse a lot less as you turn pages through the employment section way more.