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.
* 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.
"I have found that TDD has help me move much closer to the OO end"
I found this as well. TDD forces you to think and design at a much more granular level...almost inside-out when compared to procedural.
To get a good handle on this kind of low-level "OO-ness" try Bjarne Stroustrup's ) writings.
Ah yes Bjarne Stroustrup, the guru that created C++. Thanks for the link.
This reminds me. I should put up a bit about my background somewhere on my site.
Maybe I should clarify what I mean by each of the extremes. The interesting thing about an extreme is that once you are there you find actually there is still some way to go. Eventually you get to a point where you say “yes I could go further but I don't think I would gain enough out of it to be worth the effort”. I am planning to pick a small project and see how close to the extreme I can get.
Post a Comment