30 years of OO programming – My reply to a critic

I read an interesting article over on Medium that is getting a lot of views and even more comments. The article is “Goodbye, Object Oriented Programming“. It goes through and attempts to debunk the many aspects of “object oriented programming”, from inheritance to polymorphism, the author hits them all. There is only one problem, every example you show has a proper object oriented solution for it. As Morpheu5 also explains in his response:

I’m just going to say that you sound like any of the many frustrated programmers — even long-time, very experienced programmers—who probably don’t have time, will, or resources to take steps back and evaluate the situation – link

This response is spot on. Every single OO language from Ada, C++, Java, C#, to Swift and many more, all have “pitfalls” and they all have their strengths.

Commodore Vic 20

My programming started in the early eighties with Assembler and BASIC. I then soon graduated to C and then C++. I wrote a lot of C++ without really knowing object oriented programming, read a lot of books but still fell into the many traps the author speaks about above. Then, I went to school for the military and learned Ada. This is where I was actually taught Object Oriented Programming but most of all I was taught the basics of OO along with Design Patterns. In the early 90’s I bought one of the most useful books I have ever bought for programmers – “Design Patterns: Elements of Reusable Object-Oriented Software“. It changed the way I coded and most of all it changed the way I thought when addressing problems. Morpheu5 hit the nail on the head, designing good Object Oriented classes is a skill and some even call it an art.  A colleague of mine was really big on patterns, Chuck, and he pretty much shot down anyone’s code (including mine and he reported to me) that was in his words “crap” if it didn’t fit nicely into an established pattern or used OO properly. You have to have this discipline or at least someone on the team that is a “code Nazi”.

Structural patterns (essentially most of the problems in the original article were structural problems) like Decorator or Facade could easily solve some of those or even the Bridge pattern.

If you want to see really good OO, you most likely have to look no further than the language itself, Generics for instance have transformed the way we code:

Java:

while ( iterator.hasNext() ) {
System.out.println(“value= ” + iterator.next());
}

Swift:

for name in names {
print(“Hello, \(name)!”)
}

Python:

for label in labels:
if label in path:
return label

And those are just Loops, and if you don’t think that is OO, try doing that in C or Assembler and have it still be “generic”. I will end with, it takes time to learn Object Oriented Programming but it takes even more to be good at it. Use the well established patterns in whatever language you use and you will ultimately reap the benefits of a good OO design.

This post was originally posted on CodeByLarry.com.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.