I was trading some emails with someone and we were casually mentioning when we 'got' test-driven development. I thought I'd blog about when I 'got' object oriented programming. I fondly look back, almost like a summer night, back seat story when you finally have an epiphany and are never the same since.

I was a computer science student at Bradley University, maybe 1996 or so. I think I was in a Data Structures and algorithms class. I didn't 'get' OO as part of my school work though. For some reason it just didn't click with academic explanation.

While going to school full time I also worked as a programmer for a company called Affina in Peoria, Illinois. I started as a COBOL programmer and was as much of a pain in the ass as I could be to convince my leadership that I should be doing something besides COBOL.

The company previously transcribed entire manuals into a proprietary knowledge base system. This was so the in-bound call center operators could answer questions about cars from a major European manufacturer. The system really amounted to a bunch of searchable web pages except it was entirely proprietary and required a proprietary viewer to see the documents. However all of the data was kept in an ASCII text markup language, albeit proprietary (of course).

I was tasked with turning the entire hunk of information (some 30 manuals or so) into an HTML based format so that they could be viewed from a web browser. I initially wanted to use C++ because that was what I was primarily used to working with at school. However, I had the good fortune of working with (and sort of under) Uche Ugbuji. Uche was open to letting me use C++ but he suggested something a little more easy to work with since all I was doing was text parsing and it wasn't a production system. He suggested I work with Python.

I should note that the proprietary markup was not well formed XML, so whipping on some XSLT (was it even around back then) was not an option.

Python was incredibly easy to learn. I almost chuckle when I see job listings that require Python experience because any competent developer can pick it up quickly. So began my continual love affair with Python. As an aside, if Python had an elvishly handsome self aggrandizing viking as it's cover boy instead of Guido Van Rossum I'm sure it'd be the monster that Ruby is today, but I digress.

In the academic introduction to OOP you might deal with artificial things like animals. Maybe you'd have a super class mammal, it'd have sub-classes cat and dog. Then you could get all your mammals together and tell them to talk, some would say 'woof', some would say 'meow'. Somehow explanations like this didn't click with me, I didn't see what this was buying us for the complexity it introduced.

In doing the text parsing I began to create objects that handled tags. Some tags shared behavior so I'd put that in a shared super-class. Creating an object that would be able to parse a proprietary tag and create an HTML tag started to become a trivial task. I wasn't re-creating behavior un-necessarily. I even started using more intricate inheritance like tags that had a beginning and an end and tags that didn't. Finally I got that this object oriented programming thing might be useful. From then on I started to see problems in objects. The language I still think in is Python even though I've been a Java coder for over 10 years.

What we were left with was pretty darn cool. Without having to re-do any of the data entry we could now let operators view the information. The customer could even offer all of the manuals on-line so that anyone could see the information with a simple web-browser. I even re-created functionality like pop-ups and other JavaScript coolness.

So yeah, in a nut-shell I 'got' OOP while doing text-parsing in Python.

blog comments powered by Disqus