Your Beliefs About Global Warming Are Still Irrelevant

Note – I originally posted this back on January 29, 2007 in response to a letter in our local paper. I find it interesting that some of the points I made way back then are still relevant today. I have added some footnotes, since I wanted to both edit the original text, and keep this as close to the original post as possible.

Original Title: Your Beliefs About Global Warming Are Irrelevant

This letter appeared in today’s Mobile Press-Register, and it raises a few questions about the science and politics behind the so-called global warming “debate”. I’ll present it in it’s entirety, and will then address some specific issues.

Global warming claim a ‘hoodwink’

Nancy Pelosi, in addition to being speaker of the House, has apparently become a climate change expert. Her proclamation that global warming is an undeniable fact is bold, authoritative and for the most part correct, except that human activity cannot be proven to be its cause.

Continue reading “Your Beliefs About Global Warming Are Still Irrelevant”

Implementing Fizz Buzz In SPL – Shakespeare Programming Language

I recently participated in a coding challenge where the goal was to implement the Fizz Buzz problem, a simple programming task, but do this in some unusual way.

My first thought was that I should try to use an Esoteric Programming Language. Given that I didn’t actually know any esoteric languages (esolangs?) I needed to find one that I could learn well enough in  the available time in order to implement Fizz Buzz.

After looking at and rejecting options like Malbolge, which was clearly an attempt to punish someone, Whitespace, a language that only uses space, tab, and linefeed characters, I found the Shakespeare Programming Language (or SPL).

SPL is described as, “A programming language created with the design goal to make the source code resemble Shakespeare plays.”

Boy Howdy, does it ever. Here’s an annotated example of my Fizz Buzz solution, where I print Floof, Bang, or Wham instead. Why, you ask. Those were the requirements.


First, we introduce the application name and define some variables. Here, you’ll see that I’m using the Perl module Lingua::Shakespeare, which made running this in windows pretty simple:

The first line is a Perl directive to treat this file as a Shakespeare program.

Following that, we have the name of the program, which starts with “A Play” and continues to the first period.

After the program name, we have the “Dramatis Personae” – the characters who participate in this “play”. Each line defines a variable with a name and an arbitrary description delimited by a comma, and ending with a period.

After this section, we enter the program flow. In Shakespeare programs, there are several concepts that need to be understood:

  1. The actors (variables) can only perform operations when they are “on the stage”
  2. Only two actors can be on the stage at the same time
  3. Program methods/functions appear as Acts and Scenes. The program starts with Act 1 Scene 1, and continues until all characters exit the stage.
  4. Branching can be done by having one actor say to another actor, “Let us proceed to Scene X”, where Scene X is the name of another Scene (aka, another method).
  5. If there is no branching, the Scenes flow linearly from one to another.

Continue reading “Implementing Fizz Buzz In SPL – Shakespeare Programming Language”

A Case For Using The @VisibleForTesting Annotation

There are times when software developers are reluctant to write unit tests. I’m not going to dwell on how this attitude is ultimately self defeating, and something monstrous, but there it is. Professional developers are, at times, reluctant to write unit tests. Even though there are so many negative consequences for failing to adequately cover one’s code with clean unit tests, developers sometimes resist unit testing. I know this happens, because I’ve felt that reluctance as well. This is hard for a professional to admit without feeling somewhat dirty, but sometimes we need to admit that we’re lost before we can begin to find our way back.

For me, one of the key reasons I’ve heard the “don’t bother testing” devil make a compelling case while whispering in my ear is that I usually work with legacy code that often has very low unit test coverage. By very low, I mean typically in the range of <1% to 5%.  In these kinds of projects, essentially without any unit tests, developers are faced with the daunting task of writing a substantial amount of new unit code tests just to be able to get to the code branches that include the new code you’re adding or modifying.

Continue reading “A Case For Using The @VisibleForTesting Annotation”

MelonJS Space Invaders

MelonJS is one of several HTML5/Javascript game engines available, and it’s actually not too difficult to work with. There’s some really good documentation at as well as two very good game tutorials. There’s a platformer tutorial here, but the retro gamer in me was really drawn to the space invaders tutorial. I was worked through the space invaders tutorial as part of a “coding carnival” at work – basically a coding challenge that had the goal to implement one of three classic video games. I wanted to do the space invaders type game, so I selected that option.

When you finish the MelonJs space invaders tutorial, you have barely playable game. The player can shoot at the ever-encroaching invaders, and rack up points for enemy kills, but there’s not much more than that. Obviously this is the point of the tutorial – get the game developer to a point where they have created a really basic game, and provide them with the basic building blocks to be able to take their game to the next level.

After completing the space invaders tutorial, the first thing I wanted to add was enemy fire. In the basic tutorial, invaders moved as an implacable force down the screen toward the player, but they didn’t actually shoot at the player. Before I could do that, I found that I needed to alter the player object so that it extended the me.Entity object rather than the me.Sprite object that’s provided in the tutorial. This would allow my new Enemy_Laser objects to be able to collide with the player.

In addition, I wanted to use some of the original imagery and sounds from the classic Taito Space Invaders game, so I Googled until I found the resources I wanted. Afterwards, I used Photoshop to create sprite images for the invaders as well as the player. I was able to add sound effects that were sampled from the original game, and I found that this was definitely taking me in the right direction.

Once I had the enemies shooting back at the player, I needed a way to throttle the enemy fire. While working through this, I introduced something that I’ll call the alien rain of death by virtue of using one equal sign in a conditional test rather than two. Remember kids, when you say something like this:

if (myVariable = someValue)

in Javascript, you’re doing an assignment of someValue to myVariable, and the return value is ALWAYS TRUE. So, if you do that in a while loop, it will never end. And if that loop is spawning enemy fire, well … you are completely screwed.

One of the things I found was that MelonJS provides audio features, but you have to be careful where/when you play a looping track.

For example, when I added the mothership, I wanted the audio file “ufo_highpitch” to play while the ship was on-screen. It turns out that you need to place the looping audio track following your animated sprite. For example:

Another thing I realized was that I would be easier to accumulate player shots and use this counter to trigger the spawning of the Mothership rather than using a timer. I created a MotherShipContainer class to manage spawning and reaping mothership instances, and I initially thought I could use a me.timer method to control when to spawn the Motherships. This approach was really wonky, and led to fantastically weird results. So instead, I decided to accumulate player shots, and use this as a way to spawn Mothership inastances.

The code for the accumulator and how it was used is below:

Here, notice the accumulate functuion. This is simply incrementing a counter every time the player shots. Then, in the update() method, the shotCount is compared to the randomly-selected threshold value. If we hit that value, then we spawn a MotherShip. Notice in the spawnMotherShip method, I reset the shot counter as well as the threshold value.

There’s plenty more to discuss about this game, so I’ll tackle these additional findings in future posts. For example, I had fun trying to figure out collision detection, and I’m sure there are things I can do to improve the HUD and UI.

Oh yeah, you can play my version of Space Invaders here. If you’re interested in the source code, you can find it here on GitHub.

Image Matters for Remote Workers

It’s becoming increasingly common for software developers and other IT professionals to work remotely. While the amount of remote work required may vary among different companies and across the field, I think it’s likely that the trend will continue. As enabling technologies improve, web-based video calling and shared-desktop applications will be ubiquitous, and both employers and remote workers will see increasing value and share positive experiences with remote work arrangements.

Technology alone, however, cannot take the place of our social skills – you know – those abilities we’re supposed to develop that help us get along with others. In this post, I’m going to focus on video conferencing technology, or rather, on how we use it. I’ll focus on some simple things you, as a remote worker, can do to improve how your audience views you. This can be critical, since your audience is often comprised of your coworkers, managers, or most importantly, your customers.

In my work group, software developers regularly communicate with customers using video conferencing software. We all know how to use the technology, but after just a few months of meeting with developers and customers on these conference calls, it’s clear that there are individual differences in how we use the technology. I felt that someone needed to broach the topic of being aware of your on-camera self. Yes, self-awareness is a thing, Google it.

If you’re the consultant, or a remote worker trying to impress a manager skeptical of the benefits of remote work arrangements, you need to know how extremely easy it is to set the wrong expectation or make a bad impression. Below are some things to think about – preferably before you get on one of those really long video conference calls.

Continue reading “Image Matters for Remote Workers”

Struts 2 Dynamic Method Invocation

java1I’ve been doing plenty of Sruts2 work lately, and have used wildcard method mapping quite a bit. Wildcard method mapping is one way Struts2 allows a developer to flexibly call methods other than execute() on your action classes. Recently, however, I had reason to check out another flexible method calling feature in Struts – Dynamic Method Invocation.

The struts documentation says this about Dynamic Method Invocation:

Dynamic Method Invocation (DMI) will use the string following a “!” character in an action name as the name of a method to invoke (instead of execute). A reference to “Category!create.action”, says to use the “Category” action mapping, but call the create method instead.

So basically, instead of changing your struts.xml file to support flexible method calling on your actions, you could simply target specific action methods my using the actionname!methodname.action format supported by DMI.

Of course, there are potential security risks with this, and Struts 2.3 adds the ability to restrict the methods that you can use DMI upon. Also, the Apache docs state clearly that wildcard method mapping is preferred over DMI.

If you have a Struts2 application that faces the internet, please consider disabling DMI, or at least providing a set of allowable DMI methods. Be aware that you have to explicitly disable by setting a constant in your struts.xml (or file. Since DMI enabled by default, your application could be at risk if you don’t manage how users access your action methods.  

For example, adding this line to your struts.xml will completely disable DMI:

Given that our usage involved an internal application, we found that DMI helped us solve a problem quickly and cleanly, and its use in our application outweighed the potential for abuse.

Yes, Employment is Definitely Better Than the Alternative

handshakeIt took almost nine months, roughly the length of a full-term pregnancy, for me to find a new position. I’m not going to draw parallels between being born and being employed. Still, I found I was as impatient as any expectant parent to finally be done with the seemingly endless lead-up to the big event. Now that it’s over, I’m amazed at how much better I feel.

For anyone still looking, I don’t know that I can offer any words of encouragement other than the usual, trite nothings that everyone told me. It’ll get better. Something good is bound to happen. That sort of thing.

Even so, if you’re looking to make the shift from unemployed to employed, I can at least relate my own experience. It seemed like an unrelenting storm of worry and uncertainty. And at times it seemed like it might never end.

But it does.

It may not seem like it, but I think if you keep plugging away, keep sending out those resumes and taking calls, and reading the job boards, and forums, that eventually you catch a break. You eventually nail a good interview with a good employer, and they invite you to join their team.

And then you get to look back and watch that unemployed patch recede into the past, like a bad dream from which you’ve finally awoken.

Unemployment Sucks

This is my first real post on my newest blog.  I used to write on and on a few other blogs, but work became pretty demanding and I didn’t feel quite like making the time to sit in front of a computer and write in my spare time. That’s probably because I spent much of my workdays in front of the very same computers that I would blog on. You can do that when you telecommute, FYI.

All that ended last October when, after more than 15 years with the same employer, they decided that my services were no longer required, so I was “separated” from my position.  That’s the word they use now. Not fired, nor let go, nor laid off. If your position costs too much, your employer may decide that a separation is in order. One might not often see comparisons to a shaky marriage in a relationship between an employer and employee, but when that relationship ends, some of the parallels come into stark relief.

So what’s an unemployed IT geek to do? Find a new job is still number 1 on the to-do list, though I am not going to hold my breath on that score. Yesterday marked my 4 month anniversary of not working, and while it was nice for the first couple weeks, it stopped feeling like a vacation months ago. I know I’m not alone, and there are folks out there who have had it much worse than I have. I salute you all.

I found this list of reasons why unemployment sucks, and I have experienced many of them already. While I don’t want to experience all of those items, I think one thing I can do as an unemployed geek is go back to writing. It doesn’t matter if anyone reads this. This is my blog, and it’s going to be part of my strategy for coping with being unemployed.