Posts Tagged ‘programming’

Mocking and stubbing in Groovy with ‘with’

October 5, 2009 1 comment

I often use metaClass in Groovy to create mocks or stubs in my unit tests. Recently I’ve discovered that the with method makes this a bit simpler.


Foo.metaClass.with {
  doSomething = {
    return true
  anotherThing = {foo ->
    assertEquals 42, foo

is slightly shorter than this:

Foo.metaClass.doSomething = {
  return true
Foo.metaClass.anotherThing = {foo ->
  assertEquals 42, foo

and less code means less bugs.

[Update: For more explanation of why the with method is so great, read this post.]
[Update: And for another way to write your mocks and stubs, see my previous post on mocking with Groovy.]


The world hates certifications

September 4, 2008 4 comments

You’re in IT and you want to increase your value. You ask your friends “What can I do to make more money…. er, um, I mean become more valuable to the, um, shareholders?

A few years back you’d be told to get certified. In the Java world, this typically starts with the SCJP exam.

But times have changed. Folks don’t look at certifications like they used to. The romance is gone and the certs have lost their former sparkle.

Even Certification Magazine, best known for its salary survey, threw in the towel went “green” by shutting down production of the paper magazine to go totally web-based this July.

How did certifications fall from grace?

For starters: Open Source. It used to be that certifications were the obvious choice for increasing your value because there wasn’t much else out there. Now, participating on an open source project is among the best ways to make your résumé stand out. You can make the same argument for blogs, which are a great way to portfolio what you already know. Certs are soooo out of fashion. We’re all about Value 2.0.

Some have become jaded by horror stories of some hack that had a dozen certifications but was a ninny-pooper (NNPP) to the project.

Time to put my cynical hat on and question your intentions. Why do you want to be more valuable?

You want to make more money. Right? If that’s all there is to it we can stop right now – certifications probably aren’t right for you. What you need is a get rich quick scheme.

OK, if there’s more to your intentions than dreams of sipping margaritas on your own private island, let’s continue.

My hope is that you simply enjoy becoming better at your craft. Studying for a certification will make you better. Look out! Here come my greatest detractors saying:

But you don’t learn to program by memorizing APIs, you learn by doing it!”

I can empathize with this. If you are about to have a complicated brain surgery (yes, your brain) would you rather have a surgeon who has performed the same operation 100 times or some dude that memorized a medical encyclopedia? If you have half a brain, you’ll pick the surgeon with experience. If you picked the other guy, you probably don’t have much to lose anyway.

You just had to evaluate two different kinds of knowledge: how-to vs factual.

That’s not totally true. Despite my efforts, this wasn’t a purely how-to vs factual question from your perspective. Think about it. You carried an assumption that the surgeon with how-to knowledge also had an equal amount of factual knowledge but that the encyclopedia memorizer probably hadn’t so much as touched a scalpel. I’m not pointing fingers, these are intelligent assumptions you made.

You don’t have to be a great surgeon to memorize a book and you don’t have to be great programmer to get certified. 

BUT – factual knowledge will help you develop your how-to knowledge faster and better. Having factual knowledge of an Intercepting Filter (SCWCD exam) will help you to identify a great potential solution for all the unmaintainable boilerplate code you’ve been putting in your servlets. Having factual knowledge of classpath declarations at the command level (SCJP exam) will help you to troubleshoot a missed dependency even if you’re using an IDE.

Your how-to knowledge scaffolds off of your factual knowledge, just as your factual knowledge builds alongside your how-to knowledge. Learning the facts first is about knowing what tools are available, learning from other’s mistakes, and standing on the shoulders of giants.

Get certified. The factual knowledge will help you to make better decisions as you build on your experience. When you do get certified, be humble and realize there’s still a lot to learn on the how-to side. You don’t want to become a ninny-pooper!

What Makes a Great Team? Hustle.

August 6, 2008 1 comment

From The Mythical Man-Month (emphasis mine):

A baseball manager recognizes a nonphysical talent, hustle, as an essential gift of great players and great teams.  It is the characteristic of running faster than necessary, moving sooner than necessary, trying harder than necessary.  It is essential for great programming teams, too.

Why is this so important?  To paraphrase Brooks, it’s what makes a project meet its deadlines.  When developers work harder than necessary, they create some padding in the schedule for the setbacks that will inevitably occur.

I always just assumed that the great programming teams had very intelligent developers with lots of knowledge and experience.  I had never considered hustle to be an essential characteristic of a great team.  But now that it’s been brought to my attention, I couldn’t agree more, and can’t see what could be more valuable.  I’d pick a team with average experience who knows how to hustle over a team with lots of experience that doesn’t.

This has inspired me to hustle while I’m working.  I want to be a great programmer.  I’m going to work faster than necessary, move sooner than necessary, and try harder than necessary.  And that’s not enough – I want to inspire the others on my team to do the same.

What’s the most fun you’ve ever had… programming?

May 4, 2008 8 comments

Like every kid that’s ever owned a guitar, I dreamed of becoming a rock star. These days my only goal musically is to keep having fun playing music. Hey, and sometimes fake instruments are just as fun as the real ones!

Similarly, I used to dream of becoming a programming rock star. I wanted to be a speaker at conferences and have other geeks ask for my autograph. These days my only goal is to keep having fun playing with Java and any other cool languages I can get my hands on. Groovy is pretty high on my fun list these days.

Seems like a simple thing to do: Have fun.

Having fun is important. More important than being a superstar. More important than a huge paycheck.

I love asking other programmers what’s the most fun they’ve ever had programming. I especially love to ask this question when I’m giving technical interviews. More often than I’d expect, many programmers claim that their current project has been the most fun.

Riiiight. So, why are you leaving? Oh, I’m sorry, looks like we’re out of time – it’s been a pleasure speaking with you *click!*.

So what’s the most fun you’ve ever had programming? Your answer will reveal a lot about you.

My answer? It was a college project. I was on a team of three that made a functional Trivial Pursuit client/server game. Actually, the other two guys on my team were really busy with other activities so I did most of the coding myself. I spent two or three weeks of late nights to complete it. I completely skipped my final Philosophy project that semester so I could program (resulting in one of the only B’s on my college transcript), but it was totally worth it. I had a blast!

That was just one example of fun for me. I have many others like it aaaaand probably nearly as many projects that… fall on the other end of the spectrum, to put it kindly.

What about you? What’s the most fun you’ve had? What was so great about it? You might be surprised what you learn about yourself in dreaming up the utopian project setting. Of course, I’m assuming I’d be a part of your all-star team! Right? RIGHT?!

So, like I said, I don’t care about being a programming rock star, but that didn’t stop me from picking up a copy of Rock Star Programmers recently. I plan on reading it this month along with about a dozen (literally) other books (can you believe I’m just now getting started on this classic!?!). I still believe I’ll do great things in my career and I hope to find inspiration from the stories of others that have done great things and, more importantly, had fun in the process.