The Pragmatic Craftsman :: Simplicity from complexity : by Stanley Kubasek ::

Thoughts on Object Oriented Programming

Object Oriented programming is hard. It’s easy to program in a language like Java, but hard to get it right. Why?

Because Object-Oriented programming is more than just writing classes and methods. OO programming is way more than that.

I think the hardest thing in OO programming is the ability to create objects with cohesive functionality. The ability to assign responsibility well is the key to object oriented programming. And that is hard.

To see where you are, ask yourself this question: what is an object? Is it an instance of a class? Or is it a data structure? If any of those two, you don’t think in objects.

I think to truly program in an object-oriented way, you have to treat your objects as a set of responsibilities. Object oriented programming then is creating and assigning responsibilites to different objects. OO programming is creating a set of objects that are able to collaborate to achieve a task.

Also, it’s important to spread the functionalities (more or less) equally to several objects. It’s important to have objects that do several (Grady Booch recommends 3 to 5) of related tasks and do it well: specialized (cohesive) objects. That’s why your classes should not be too large. It is a sign that your class does too much — it has too many responsibilities — if it is large. It’s usually good then to break up that class into more specialized classes.

The biggest benefit of OO, I think, is the ability to think more abstractly. It’s the ability to concentrate on a higher level. It’s like programming in Java vs C++. In Java, you don’t have to worry about pointers and references. You are working on a higher level. I think you can accomplish more that way (and save your brain for other tasks ;-) ).

To be a good programmer, better coder, you have to be a good OO programmer. It’s not an easy thing.

2 Responses to “Thoughts on Object Oriented Programming”

  1. Hoodlum Physicist says:
  2. Stanley Kubasek says:

    Hoodlum,
    Thanks for a great response!
    I’m more of a “craftsman” wannabe. I want to become one by constantly learning, constantly getting better — you summarized it nicely. :-)
    One thing that I like is clean, simple solutions. I work hard to achieve that — I have not seen too many solutions like that in the workplace. And that — making complex things simple — is the hardest part of programming — crafting. :-)

Favorite Quote

Topics

Tags

Archive

Currently Reading

Info

© 2001-2024 Stanley Kubasek About me :: Contact me

Me on Twitter

»see more

Recent Entries