Thinking in OO way

Thinking in OO way

Most of the times when we get new developers in Java World, as senior developers and Architects we advice them to think in OO way. What does it mean? We may take some example within the project or in general like Vehicle as ” Object ” and list down the properties or attributes of any vehicle and list down the nationalities which are common for all vehicles to define the interfaces.

Then we will straight away move to inheritance, encapsulations, abstraction concepts. But if we take a step back and think why these names are given for these things in Java by learning their real meaning of these words, we might explain things in Java in a different way. And for the learners also it would be much easier to relate Java to reality.

Object Oriented Programming (OOP), If I understand the philosophy behind Object correctly, “A material thing that can be seen and touched.” Are our Java Objects can be touched or seen ? That is not the reality, so our Objects are the simulations of real world objects. That’s the reason why Java is Object Oriented (OO) language. In any real project we take the real objects and try to simulate their properties and behaviors in Java, this is called as OOP.

Then we should understand the other terminology of Object orientation. I will try to cover very important one’s here.

Inheritance, This looks like a biological term if you are not a programmer. It may even look like Law term if you are a lawyer 🙂 , The real meaning of it looks like this – “The process by which traits or characteristics pass from parents to offspring through the genes.”  In our OO context it applies to the classes and their behaviors. It is exactly the same as what we do get from our parents as inheritance.

Encapsulation , This is a general English term used to wrap something in another, The dictionary meaning says – ” to enclose or be enclosed in or as if in a capsule“. It is very easy to apply the same idea to the object. We would like to encapsulate the data inside the object – thinking How? using simple concept of Bean, Using private attributes for class and use getter and setter methods wherever required to access the data in these private attributes. This is how we secure/ wrap / capsule  our data using encapsulation.

Abstraction, This word means – ” Existing in thought or as an idea but not having a physical or concrete existence “. So, Its easy for us to understand when we have the idea on the functionality, but we are not sure what exactly it means. How we can achieve this in Java ? – Using Abstract Class / Interface. We will define interface when we know the common functionality which is abstract  at this point and can be implemented in any way you want in future.

So, this way we should first understand the real meaning of any concept we would like to understand and try to relate the things to the classes, Objects, methods, attributes etc.

Wish you happy reading 🙂

Best example of OO thinking –  This image courtesy –

OO thinking
OO thinking

One thought on “Thinking in OO way

Leave a Reply

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

You are commenting using your 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 )

Google+ photo

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

Connecting to %s