Everything I know about Code Reviews I learnt from Star Wars (and JCooney)

Imagine you're on a project where Joseph Cooney performs code reviews on everything you try to check in...just theoretically. And, theoretically, people like Don Syme and Joel Pobar are on hand to provide useful feedback at times...

Many many iterations ago... in a project far, far away...


Joseph (in red, indented)Leon (in blue)
Aren't you a little short for a developer?Don't underestimate the Force.You may dispense with the pleasantries, Bambrick. I'm here to put you back on schedule.So, can I can check it in? You like my code?You'll never find a more wretched hive of scum and villainy.We must be cautious.What's that line of code there?It's an old code, but it checks out. I was about to check it in.Does it compile?I find your lack of faith disturbing.

This part uses composition. The weapon of a true coder. Not as clumsy or random as code generation or polymorphism; an elegant design pattern for a more civilized age.
Don't be too proud of this technological terror you've constructed. The power to destroy performance is insignificant compared to the power of an enterprise rules engine.We shall re-double our efforts...I hope so bambrick for your sake. The build master is not as forgiving as I am.Look, Your Worshipfulness, let's get one thing straight. I take orders from just one person: meIt's a wonder you're still alive.It's a valid implementation. Screaming about it won't help you.Let 'em defect it. It is not wise to upset a tester.But Joe, nobody worries about upsetting a developer.That's 'cause devs don't pull people's arms out of their sockets when they lose. Testers are known to do that.Wonderful girl. Either I'm going to kill her or I'm beginning to like her.So I'll check it in?I have a very bad feeling about this...[pauses]

It's a TRAP... err CRAP
Damn fool, I knew you were going to say that.Your insight serves you well. Bury your feelings deep down, LB. They do you credit, but they could be made to serve the rules engine.

You can write this shit LB, but that doesn't mean we can checkit in.

Last resort: use Jedi mind tricks on Joseph:

These are not the bugs you're looking for (wave hands)These are not the bugs we're looking for.
You may go about your business. Check it in.

(that's a fairly typical back and forth).

 

Syntax highlighting of strings

Maybe this is a fiddly little point, but I think it's the sort of detail that's worth paying attention to.

The theory is:

Syntax highlighting of strings could be improved to make reading easier

In the following code example, look at the way the string is 'highlighted':

return string.Format("<a href=\"{0}\">{0}</a>", link);

The red highlighting covers not just the literal string itself, but also the quote characters and the escape characters: the 'meta' guff that decorates the string.

So in the previous example, there's no clue given to the naked eye that some of the quote marks are "literal" quote marks, and others are delimiters to mark the beginning or end of the string.

Instead, syntax highlighting gives up, right when it could be most helpful. And it's left as a parsing exercise for the programmer to determine what is and isn't really a string.

Here's a different way the syntax highlighting could be implemented:

return string.Format("<a href=\"{0}\">{0}</a>", link);

Now colour (actually -- saturation) is used to differentiate between the literal parts of the string, and the 'meta' parts of the string (the escape characters and the quote delimiters).

It looks strange at first glance, because it's an alien concept -- but i think that if you were used to this type of highlighting, it would allow you to "see" what escaping is going on in a string, far more readily.

More importantly -- it allows you to selectively 'see past' the escaping.

If you look at the second example, you can 'train' your eyes to focus on just the literal string itself -- until you see basically:

return string.Format("<a href=\"{0}\">{0}</a>

And thus you can reason about the text you've written, or proof-read it, in greater isolation from things that only the parser needs to worry about (the mechanics of escape characters etc.)

 

Google AppEngine: evil virus or viral evil?

google app engine is interesting

After reading all the negative publicity that google's new application engine is generating -- I couldn't believe my eyes!

Could it really be that bad?

Or are these people just crazy paranoid schizofreakazoids with nothing better to do than write mealy-mouthed whinge posts about a whole pile of baloney?

So I signed up, downloaded the sdk, and got my hands stuck right in there. Then I waded through all the contractual jibber jabber and came to my own conclusion:

Yep, evil.

Read the fine print guys! Sheesh!

Every page of your application must have the "Google Rocks" logo in all four corners. The only language you can use is Gython -- Google Python, accessing your data via Gorm -- the Google ORM. The cost is fifty bucks per click -- that's google dollars -- bought at the google exchange rate. Plus, your code gets locked in Google's basement (aka GFS) for ever and ever.

Serious though, this cloud computing stuff (see also EC2 from Amazon, IBM blue cloud) looks pretty amazing.

Cough, cough, (Just making sure Ray Ozzie is awake). I'm going to say that a little louder.

this cloud computing stuff looks pretty amazing!

You freakin' got that yet Microsoft?

And this is just the very early days.

We will hear a hell of a lot of hype about this concept yet.

Then we will go through a bitter trough of disillusionment.

And then there will arise that grand surging tide of productivity as the vision is finally realised, five years from now, by which time we'll all be considering it old skool, as we float around in our hovering moped-atron-segways, reading e-newspaper articles about how Wikipedia bought Microsoft in exchange for a vintage single core computer from the e-smithsonian.

And then apple will put out a hand held elastic compute cloud, and six-year-old african kids will be wearing them as a fashion accessory.

Ah, back to reality:

Google will soon unveil Ruby as language number 2 on the platform. This right now... this is just the fluffer ;-)

 

Perfect for lounging

--Why do you hate workflow so much?

My only problem with workflow software is that you have to sell your soul to the devil first.

--And that's a conflict of interest, since you already sold your soul, right?

Technically, yes, I sold my soul already. But it turned up on ebay and I bought it back.

--"One soul. Hardly used. Lacks ethics and morality. Perfect for lounging. Supports upgrade to 'weasel'."

You read the ad?

--Read it?! I almost out-bid you.

 

Meeting Frustration, Chaos and Despair Head On. And loving it.

Marcus Auerelius was a chump. Cleverer than I, and emperor of the modern world. But a halfwit, at best.

Old Marcus A. spake thus:

"Begin each day by saying to yourself, 'Today I shall meet people who are interfering, ungrateful, arrogant, deceitful, envious, and selfish.' They are made this way because of their ignorance of what is good and evil... but I, who have seen the nature of good and beauty, and of evil and its ugliness, know that the inner nature of the man who does evil is the same as mine, therefore I can't be harmed by any of these men, for no one can impose on me what is degrading."

Yet my philosophy is richer, though -- at a glance -- far poorer.

For I add to this outlook the respective wisdoms of Newton and Hanlon:

An object will stay at rest or continue at a constant velocity unless acted upon by an external unbalanced force

...and...

Never attribute to malice that which can be adequately explained by stupidity

Hence, with my modern stoic attitude, I proudly announce:

I begin each day by reminding myself,

"Today I shall meet with frustration, anxiety, anger, antagonism, annoyance, mistrust, frivolity, ignorance, hubris, jealousy, laziness and despair.

But things must be such, as we are born in ignorance, and continue as such -- without tremendous interference. Momentum, entropy and the scourge of complexity lead all of us toward chaos, panic and compromise, despite the most industrious of minds and the noblest of hearts.

If, on tiny occasions, we succeed at bringing joy in place of despair, knowledge in place of ignorance or order over chaos, no matter how insignificant is our victory, we shall smile quietly and confidently, knowing that having beaten nature, we will be punished with ample severity."

 

Workflow software: I'm calling the bluff.

I could be completely wrong about this -- but I'm just going to make some bold and disparaging remarks about the whole existence of workflow software and see what happens.

Here we go.

A state machine is about the most basic electronic circuit you can make. You can throw one together with a couple of transistors.

And in software, writing a state machine is so simple that it's hard not to write one.

But simple ideas leave room for big inflation. Sales people know that the best things to sell are inflated big ideas.

So the field of Enterprise-Level Workflow Software was born.

And businesses buy them, happy to take a short-term hit in productivity, since it will lead to long-term benefits. But when you buy an expensive wrapper around a five dollar piece of softeware, the long term effects are confusion, complexity and further cost.

Business are universally worse off because of the advent of 'work flow' products.

I hear the response "Oh but workflow has a lot of value-add over rolling your own solution. You get persistence of long running processes, for one thing."

Persistence? Persistence? Don't we have these thing called databases? Isn't that our usual, and fairly well understood persistence mechanism?

Also there's value-added services such as logging and reporting.

Logging? reporting? I'm still thinking 'database.'

Ah, but here's the super-answer:

Lego Mindstorms NXT programming

Workflow products include graphical tools for letting business analysts design their business processes without involving coders.

Without... without... You're kidding right? You ought to smell what you're shovelling.

Show me a working 'business analyst' -- one, who is not now nor has ever been a coder -- who successfully designs 'business workflows' using an off the shelf tool, and who didn't require *any* expensive training, and who achieves their task in less time and with more precision than a coder. And who doesn't need to call technical support for help at the time.

Show me just one.

World wide.

I can wait. I give you one month. Nah, screw it. I give you eternity.


Whenever I get too saddened by these things, i think of my big idea for a whole new class of enterprise component:

The 'IF' server.

Here's the general pitch.

(switch to the kind of voice-talent they use when advertising john grisham films)

Business today is complex. You need to make decisions. But every decision will take you down a certain path. Who can you count on to get you there?

Business needs alignment.

Business processes need to work together to guarantee that decisions are made for the greater good. Or evil, if that's the business you're in. We don't discriminate against evil.

Consider a difficult decision. It may be hard to make, but with an IF server, we can serve up either a true or a false, whichever you prefer.

You can have the most complex business scenarios in the world, and if you tell us to return true, we will. Every time.

Your IT department is a complex and challenging part of your business. They control a complex array of applications, of all sizes and across many platforms. Custom software is never dependable. But an IF server, can be relied upon.

Imagine... A single standard for IF processing, accessible from across the entire organisation.

Using proven open standards, like XML -- the Lingua Franca that powers today's fortune 500 businesses -- every application can link to the same powerhouse of decision making excellence: Your IF server.

Now you know: no matter what software your team is writing, they can connect to the IF server and be given one standard result. Monday? Then it's true.

Tuesday? Then it's false.

You run the business. You decide.

No more doubt. No more incompatabilities. No more missed deadlines and lost opportunities.

You can crush the competition. You can destroy them all.

IF only you purchase now.

The IF Platform Server One Million and One. A revolution in business processing solutions.

(ahh - image courtesy of here)
 

3 Types of Argument

competing models of SU behaviour following M1

Engineering Argument:

There are two ways to implement something. Neither option is perfect -- both have their own compromises, which are known and measurable. Argument centres on which compromises are most acceptable.

Example: should the bike-shed be made from wood or brick?

Artistic Argument:

There are two ways to implement something. Both are functionally correct, but have unquantifiable differences. Argument centres on intuition and opinion.

Example: should we paint the bike-shed topaz or cyan?

Religious Argument:

There are two conflicting points of view. Both are utterly wrong. Argument has no centroid and no limiting factors.

Example: should the bike-shed be built to honour the green walrus or the almighty unicorn?

[notebook image above is 'a thorough mathematical analysis of two competing models for optimising energy dissipation through behavioural approaches to leaving the toilet seat up.']
 

F# Eye for the C# guy

This Tuesday, 18th of March, I'm giving an introductory talk about F# at the Queensland MSDN user group.

Head to Level 9 of Waterfront Place (1 Eagle Street, Brisbane City, Queensland) arrive between 5:30 and 6 pm.

Come on now! You'll love it! Forget spending time with the family -- learn a new language!

F# Eye for the C# guy

An introduction to Microsoft's newest official language, F#, geared toward C# and VB.net coders.

See how functional programming, object-oriented programming and imperative programming can work together to provide untold expressiveness.

If you only learn one new language this year, F# ought to be the one.

I've been putting the polish on this talk all weekend, and I'm very much looking forward to delivering it.

Please come along if you can. RSVP to Mike if you're interested.

 

Anonymous Methods: Now that's a dumb name!

This has always bothered me and I've never quite put my finger on it until now.

I love anonymous methods (in .net 2.0+). I've over used them, sure. I've under used them, too. And I've gotten all too excited about them.

But the name is so very wrong. It puts the emphasis in all the wrong places. Anonymous, hey? Well what've they got to hide?

Consider this chunk of code:

Dim Result as Integer = Math.Sqrt(16)

What is '16' in the above snippet?

Well, it's a value. And it gets passed to a parameter. Simple. But a different answer we could give -- if we wanted to bamboozle people right at the start -- would be:

"Well in this case '16' is an anonymous variable."

A what? A huh? A... well.. you're just trying to sound clever aren't you?

Calling it an 'anonymous variable' is only useful if you are the damn fool who's stuck with the job of writing a compiler for the underlying language. It doesn't help the regular johnny coders like you and me who code in the damn language every day. (unless the build is broken that day of course.) (or there are too many meetings that day.) (or the keyboards are wrong.)

Similarly -- an 'anonymous method' is really just a 'code block', or an 'immediate method', or an 'inline method.'

The point isn't that it is anonymous, the point is that it's a method.

Maybe the term could be "throwaway method" -- as in, it's a method that's not designed for re-use. You just use it in this one place and then throw it away.

Ah, rant complete.

Meanwhile my VS2008 beta has just expired, and my msdn subscription has just run out. I've got some serious vs2008 home-work to do in the next few days... so this is bad stuff. Bad i tell ya!

 

Who Would You Back? Really?

So I was sitting at work this week, immersed in some complex n-tier, m-dimensional, z-class np-hard problem, when cooney interjects with a gob-smackingly complexicated puzzler, that spins my mind in a vortex of impossible tangles. Get this:

"Who would you back in a fight? Indiana Jones or Han Solo?"

A riddle wrapped in a puzzle, shipped home in an enigma with pre-paid mystery and a side heaping of conundrums.

After narrowing it down (Sword or Pistols? Stock whip is allowed? Blaster is kosher? Bare knuckle or gloves?) I had the details downpat (bare knuckle, earth, queensbury rules) and took the question home to Mrs Secret Geek to ponder over dinner.

"Both are quick on the draw,"

said mrs secret geek, mostly immersed in her afore-mentioned nintendo ds

"but while Han's a short-sighted scoundrel, Indy has the superior intellect, and less reliance on the sidekick. Clearly, Indy FTW."

I went back to work the next day, happy with this answer, only to be hit with a barrage of further dilemmas:

"Who would you back? Rocky or Rambo?"

And, over lunch, many more in the pattern

"Who would you back? $0 versus $1?"

With $0, $1 represented by various combinations of the following:

  • Fidel Castro versus John F Kennedy?
  • Jesus versus Buddha?
  • Abraham Lincoln v Richard Nixon?
  • Hitler v Chairman Mao?
  • Gandhi v Mother Theresa?
  • Bradman v Pharlap?
  • Gandalf vs Spock? (note this is Gandalf the grey, not ol' whitey)
  • Dumbledore v Mr Miyagi?
  • Bruce Lee v Ryu (from Street Fighter)?
  • Michael Knight v Astroboy?
  • Newton v Einstein?
  • Webster v Arnold?
  • Tron v Neo?
  • Kevin Mitnick v Matthew Broderick in War Games?
  • Terminator v R2D2?
  • Sarah Connor v John McClane?
  • Socrates v Nietzsche?
  • Ewoks v Oompa Loompas?
  • Babbage v Pascal?
  • Voldemort v Vader?
  • Frodo v Skywalker? (luke, that is) (pre jedi training) (i say skywalker's got him on reach)
  • Gollum v Yoda v Doby -- all-in freak brawl!
  • So, what do you say, unwashed internet masses. Who would you back? And why?

    (this is one of the lower-browed posts. sorry.)