Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The general effect of the cattle drive :)

 
Katrina Owen
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Last night I was working on some code (not java) that was written by someone not me (thank God!). It is a part of an application that I have been messing with (updating, maintaining, bug-fixing, whatnot) for the last year or so. When I finish the cattle drive I am going to rewrite the whole application in java.

Anyway, I came across a section of code with multiple variations on the following one-liner in a switch statement. I've broken it up here so that the page doesn't scroll horizontally.



All sorts of warning bells went off in my head (excessive array dereferencing, redundant code, unreadable tertiary statement, a method called q() - yeah, well q() you, too! - and then the f prepended to the identifiers... what's that supposed to be? I actually think it has something to do with it being 'fetched' from the database, but jeez!

After a bit of fiddling (via a version with an if/else statement just to see what exactly was going on) I ended up with the following:



Thank you, thank you cattle drive and nitpickers! You have been infiltrating my brain, and the results are tangible!
[ June 18, 2007: Message edited by: Katrina Owen ]
 
Marilyn de Queiroz
Sheriff
Posts: 9063
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What a wonderful testimonial to read! Thank you for sharing.
 
Pauline McNamara
Sheriff
Posts: 4012
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow. Real world payoff, cool, thanks for showing us such a great example.

That application can be happy it found you.
 
paul wheaton
Trailboss
Pie
Posts: 21484
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the kind words Katrina.

Not bat for 200 smackers, eh?
 
Katrina Owen
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is so very worth the smackers, Paul. I can't believe this place hasn't been overrun.
 
Jon Anslow
Greenhorn
Posts: 16
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nice post, Katrina. My experience of the cattle drive have also been productive and an enjoyable learning experience, which I try to encompass in my coding at work and also in my studies. Some of the feedback I have received from my tutor from assignment work outside of the cattledrive are 'clear code', 'easy to read' and this has come from taking part in the drive. As a newbie into programming it has helped me gain a mindset early on how it is important to maintain readability of code, not only for myself when I come to look at my code a few months later on, but also for the fellow coders looking at my work in the future.

Even from the first assignment, I learnt something (array de-referencing), I think, like fellow cattle drivers I thought I had submitted the perfect first assignment until I received that nitpick! But this lesson helped me to understand and to sometimes rethink that although my code is doing as expected, is it as efficient as it could be?

I am glad I have been fortunate enough to learn these valuable lessons at the start part of my programming career

Jon
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic