Tip for Learning OO

Over the last few years I have talked a lot about wanting to better learn Object Oriented software development, but I have yet to seriously buckle down and get working on it. So I have been thinking a lot lately about strategies to learn OO. I want to highlight one thing that seems to hold people back, hopefully as a tip for others getting started with OO. To sum it up in a few words, don’t worry if you are “doing OO right”. Just do it. Read on to see why I say that.

I have seen a few people over the years get started with OO, and the first thing they do is reach out to the OO community for help and advice. On the surface, this seems like an excellent plan. However, this often backfires. The trouble is that just about every OO developer out there has their own opinion about how to do OO.

If you ask around about a principle, you will get answers and they have the best of intentions, but they might look at your code (or your questions) and say, “No…you’re going the wrong direction. You need to do it this way.” And then you could ask a different person and they could give a completely different response. For a perfect example of what I am talking about (the disagreement between OO people’s ideas), check out the comments under this Ben Nadel blog post. So don’t let other OO people discourage you…if you study for yourself how an OO principle should work, and then you apply that principle, you are doing OO (regardless of what some other developer thinks). Yes, your application of OO can and should improve over time…but you will never find the one and true way to code OO (because it doesn’t exist). Don’t worry if you are “doing it right”. Just do it.

I discussed the fragmentation of the OO community in a previous blog post. I don’t want to get into that again except to say that we should be aware of it when we start learning OO. The problem for new OO people is that we can often feel pulled in many different directions (by different philosophies), as illustrated by this excellent Ben Nadel blog post about practical OO programming. Let’s face it…OO is a very complex discipline, and there are a lot of very passionate people out there that have somewhat disparate ideas about OO development.

So my tip is to focus on core OO principles, one at a time. Take a design pattern like MVC, or an idea like encapsulation, and start with that. Study the principle for yourself from a book or something. And then start using it in your day to day coding. Don’t explore other principles or patterns until you feel comfortable with (and have experience applying) this first one. After you feel comfortable with it, move on to a new principle and repeat the above process. Don’t spend too much time worrying if you are doing it correctly. Just do it.

The reason I suggest that you learn one principle at a time is because it allows you to really learn it without the potential confusion of other ideas or patterns. In my experience, there seems to be some overlap between different design patterns and OO principles. So exploring multiple at the same time could be too confusing. I think taking this one at a time approach (ignoring too much criticism of your methods from others), you can slowly but surely apply OO until you feel confident about your OO skills.

As Sean Corfield always says, learning OO is a long process, and you should never really stop learning it.