Thursday, 18 October 2012

Great programming analogies No.2. Age of Empires. Part 1

This is the second in a series of posts where I plan to share some of my favourite analogies and anecdotes from my training sessions and presentations. This one is an analogy. Age of Empires.

HTML5 player

This is one of my oldest and favourite analogies.
Like many analogies, it developed and grew in the retelling until it reached epic proportions.
Many years ago I delivered a Microsoft Official Curriculum - MOC course: M2124 Programming in C#.
It was a great course and covered many of the fundamentals of programming .NET applications using C#.
A great deal of the content was devoted to classes, interfaces, polymorphism etc.
Those chapters began with a discussion about Object Oriented Programming which was a challenging concept to put across for those who hadn't come across it before. The analogy used in the book was that Car was a class. And your car would be an instance of that class.
Well OK. But it's a bit tame and needs a lot of work.
An analogy that I heard others use several times involved dinosaurs.
There was a class called Dinosaur. This was a base class. There were sub classes called Herbivore and Carnivore.
So far so good. We have made a start on inheritance.
"What's next?"
"Nothing. That's it."
"What. No polymorphism? What about interfaces? How do you explain static members?"
"And while we are explaining Object Oriented Programming - OOP techniques with C#, how do you explain / justify constructors and destructors?"
No. Dinosaurs were out. What a poor analogy. If I didn't rate an analogy, my delegates certainly wouldn't
I constantly strive to find an explanation/analogy that successfully communicates the idea that I am trying to put across. Sometimes, I might try a half formed analogy and have no luck with it at all. Other times, some of the group will see where I am going with it and contribute their own ideas. And through that banter and brainstorming, the idea takes shape. It might take a couple of courses before an analogy really comes together.
When I first began thinking about how I might explain OOP concepts to budding C# developers, the only analogy that made sense and could cover most if not all of the aspects was the computer game called Age of Empires. I used to play this game a lot. There have been several editions. My favourite was (and still is) Age of Empires II - Age of Kings (the medieval one). This edition more than any of the others had all the characteristics that I needed for my analogy. No matter what feature of OOP or C# I was trying to explain, I could always manage to explain it in terms of Age of Empires II.

Some years ago, I read an excellent article about tips for giving great technical presentations. The only tip that I disagreed with was where the author cautioned against using computer games for examples. He suggested that they were not real applications. He probably meant Line of Business - LOB applications.
Well I disagree with that one completely. Last time I looked, the computer/video games industry was huge. A much bigger market than accounting or payroll for example.
Furthermore, despite the wide variety of backgrounds and markets of my delegates, I could guarantee that on a computer programming course ALL of my delegates will have played/used computer games. Possibly even Age of Empires! The same couldn't be said for payroll applications.
In the mid 90s, I was Lead Programmer on a game called The Darkening. Well that was its name until the marketing departments at Origin and EA decided to smack Privateer 2 on the cover too.

Now believe me. That was real programming.
It's all about transferable skills. Years later, I employed the same OOP techniques to write Payroll and Computer Aided Design - CAD applications.
Now I have already mentioned that this analogy became an epic. I was able to reference it repeatedly over 3 or 4 days of the course.
It would be impractical to deliver this in a single post (although I do feel an eBook coming on).
Instead, I will deliver it as a series of blog posts.
If you are planning to work through the series, it might be useful for me to begin by giving you an overview of the game.
I'll do that in the next post.

Flash player

See you soon

Phil Stirpé
"I don't do average!"

No comments:

Post a Comment