The Pragmatic Craftsman         :: Simplicity from complexity :: | About Me |

You are here: The Pragmatic Craftsman > Better Coder

Go to: « My SOA Views | Write Self-Documented Code »

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.


Comments

I love--and, I daresay--envy gung-ho programmers like you. Well, I mean "craftsmen". I forget to use that term because it's pretty radically new to me--I'm just a "grunt programmer" or "grunt coder" mostly, and it is really inspiring to see someone like you who is constantly wanting to become MORE and BETTER at what he does--to the point where you can call yourself a "craftsman" rather than merely a "programmer"!

Keep up the good work!

-Hoodlum

---

P.S.: Your second-to-last paragraph, about the benefit of OO and the advantage of using Java for OO over C++ is a succinct distillation of something I've struggled for years to express. I can't wait to read the rest of your blog!

· November 30, 2006 ·


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. :-)

· December 1, 2006 ·


Post a comment









Remember personal info?







Go to:
   « previous entry: My SOA Views
   » next entry: Write Self-Documented Code

Random Quote

Search

 

Topics

Architecture & Design :12
Better Coder :29
Books :43
Books Recommended :18
Buzzwords :5
Career :25
Craftsmanship :15
Java :15
Quotes :25
Recommended :9
Software Engineering :3
Uncategorized :33
Web Development :1

Archive

May 2008 (1)
April 2008 (2)
March 2008 (1)
February 2008 (1)
January 2008 (2)
November 2007 (1)
October 2007 (3)
August 2007 (3)

...since January 2002

Currently Reading


:: See list of books I finished reading

Info

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