What is Object Oriented Thinking?
Object oriented thinking is the thought process in which we will consider everything in terms of object.
Consider we have a room. That room contains some tables, chairs, computers etc. Also people works inside the room. Now how we can think it an object oriented way as follows-
- Table is an object
- Chair is an object
- Computer is an object
- Person is an object
- Room itself is an object
In above example we considered each category of element as an individual object. This is called object oriented thinking.
How to think any concept/problem in object oriented way?
To think any concept/problem in object oriented way we need to follow some steps given below-
- Break down the given problem/concept into different parts based on their responsibility
- Consider each part as an individual object
- Then relate between those objects
1. Breaking down the given problem into different parts
According to above example we have a big concept room. Then we broke down the concept into different parts according to their responsibilities as follows-
2. All above are object of our concept room.
3. Now we will relate between those objects like-
- A room can contain one or more chair(s)
- A room can contain one or more Table(s)
- A room can contain one or more Computer(s)
- One or more person(s) can have inside the room
- One person can seat on a chair
- One or more computer(s) can placed on a Table
- One person can use a computer
Why we need to thinking anything in object oriented way?
Object oriented modeling is the major part of object oriented design. During translating any problem/concept to object oriented model, object oriented thinking is single most important thing we need to know because- “It represents the key concepts of our system in terms of objects”
What is object?
Objects are real life entity. Around us everything are object like dog, television, bicycle etc.
Each object has two characteristics-
1. State and
Each object has specific states/details. Those details are relevant to the user of those objects.
Person object has specific details like- name, age, gender, occupation etc.
Computer object has its specific details like- processor speed, monitor size, resolution, RAM, HDD capacity etc.
Chair object has its own dimension, color etc.
Each object has their own behavior associated with them
A person may have some behaviors like talking, eating, walking, sitting down, typing etc.
A computer has some behaviors like power on or off, performing operation etc.
In software development we will use object oriented concepts to represent the things/entities. It will help our code to stay organized, flexible and reusable. Let’s see how-
Object keeps our code Organized
Objects keep code organized by putting related details and specific functions in distinct, easy-to-find places.
Details of a person and behavior of a person will put inside Person object. Person object is a single, distinct place. So the person object’s code remains organized.
Object keeps our code Flexible
Objects keep code flexible. So details can be easily changed in a modular way within the object, without affecting the rest of the code.
From a person object we can change person’s details like person’s occupation easily. And this change will not affect the rest of the code.
Object makes our code Reusable
Objects allow our code to be reused. It helps us to reduce the amount of code to recreate. Also helps to keep our program simple.
An employee is also a person. So we can reuse the Person object in terms of Employee.
In object-oriented thinking everything considered an object regardless whether it is animate or inanimate.
A person is an object (Animate)
A chair is an object. (Inanimate)
In object oriented thinking objects are self-aware regardless whether they are animate or inanimate.
A computer knows its specification.
A chair would know its dimension and location.
Prepare for object oriented design
The good practice for prepare ourselves for object oriented design is-
- We will think everything around us in terms of object.
- Try to identify all the attributes those objects might have.
Exercise of Object Oriented Thinking
A good exercise of object oriented thinking is-
- Look around the room
- Identify what objects contains inside the room
Computer, person, furniture’s
- Identify the specific details of each individual objects
A computer system contains some specific details like operating system, display revaluation, processor speed, Virtual Memory etc. all
- Identify the specific behaviors/responsibilities of each individual objects
On and off the computer system, displaying a screen etc. is the behavior of a computer system
Even the room itself is an object! It may have a seating capacity, a room number etc. are the specific details of the room. The purpose for being the room is uses are the responsibility of the room
Best way to think everything in Object Oriented Way
So the best way to thinking in object oriented way is- think about
- What objects are around you?
- What kinds of details/properties they might have?
- What behaviors/responsibilities it they might have?
CSM, CSPO, CSD, CSP-SM, CSP-PO (ScrumAlliance.org)
Certification Profile Link-
Currently working as Lead Team (Application Architecture) at Raven Systems Ltd. Passion for software development especially agile practices such as TDD with in depth knowledge of Object Oriented Programming, SOLID Principles, Gang of Four Design Patterns, Some Enterprise Application Architectural Patterns. Over 8 years of software development experience ASP.NET. Has the ability to understand and transform complex business requirements into software ensuring applications are delivered on time. Also experience in non Microsoft .NET technologies such as Dapper.Net, Git, Structure Map & Angular, Bootstrap, HTML-5, CSS-3 etc.