Tuesday, May 17, 2005

How OO are you?

I once introduced a very smart C coder to C++. I had the pleasure of working with the guy, and what impressed me most was how he followed a coding standard of his own invention.

Namely:
* All methods take as their first parameter a structure.
* Only methods related to a structure lived in the same .h and cpp files.

Basically the guy was doing OO and didn't know it.

So... What is the opposite of OO?

I recently had to interview a guy that claimed to know C++, Java, C# and more. In the interview it turned out that he didn't like objects and preferred to just use functions and global variables. In Java, for example, his code would consist of a single class containing all methods and variables.

It seems that Procedural and OO are different ends of some spectrum. Which makes me think 'Where about on this spectrum does my code live?' I hope its up the OO end. That's my aim. I have found that TDD has help me move much closer to the OO end than I thought possible. I am going to make a conscious effort to see if I can get any further away from procedural code.

Basically I am going to try to make all method bodies as small as possible (try to get to one line) and use objects not basic types (try to pass at most one parameter to each method). Also I'll make sure no methods have any side effects. :)

We'll see how I get on.
Post a Comment

GitHub Projects