What is an Object?
An object is any thing which can be categorized, and described by its characteristics and its style of act and react depending on situations. In real life, we see a lot of living things and non-living things around us. Let's talk about few examples -
- Dog - Dog is an animal. So, we categorize dog as an animal, but dogs are different kinds. We can further categorize them like Beagle, Boxer, Golden Retriever etc. Each kind of dog has its own features like - size, weight, color, coat, and its activity style like - barking, running, licking, playing etc.
- Employee - An employee is a person with name, age, height, weight, qualifications, designation, department, salary, perks etc. Depending on the designation, employee has to work, manage the team, report to boss and complete his tasks.
- Company - A company is an organization with name, type, logo, no of employees, revenue, etc. And it works depending on its type - like if it is software company, it mainly works on software projects. But if it is a pharmaceutical company, it can manufacture different drugs.
- Numbers - Who doesn't know about numbers. We daily deal with numbers. Numbers are several kind of numbers - whole numbers, even and odd numbers, prime numbers, composite numbers. We can add, subtract, multiply, divide, square, square root, cube, factorial, fraction them. Numbers are used in different calculations.
- Shapes - Shapes can be categorized into any polygon with more than 2 sides and closed on all corners or any round shape like circle, sphere, oval, parabola. There are different methods to calculate their area, perimeter, circumference etc.
What is a class?
When we categorized objects with some common features - that is called classification. A class is a prototype which includes common features and behavior. For example -
- Dog is an animal, so dog is an instance of class animal. Dog itself is also a class but all dogs are instance of this class and have common features and behaviors.
- Employee is a class and every employee is an instance of this class. Company can be a separate class itself, and Employee class can be part of the class Company.
- Likewise, we can have different classes for Numbers and Shapes, and they can have their own methods.
Object Oriented Programming
So, when we say Object Oriented Programming, we are coding with different classes and their objects. In old languages like FORTRAN, COBOL, BASIC and C etc., code was written in procedural and structured way. The code was executed from top to bottom.
But in object oriented approach, a computer program is written by using class definition (prototype) and creating an instance of the class, object. The class definition will have variables as data (features / properties) and methods as behaviors (any kind of instructions). Examples of object oriented languages are C++, Java, Python etc.
NOTE: This is just an introduction to start to explain the concepts in an easy way. I tried to write it in very simple language and tried to use very less technical terms. In coming posts, I am going to explain more basic concepts with examples.
But in object oriented approach, a computer program is written by using class definition (prototype) and creating an instance of the class, object. The class definition will have variables as data (features / properties) and methods as behaviors (any kind of instructions). Examples of object oriented languages are C++, Java, Python etc.
NOTE: This is just an introduction to start to explain the concepts in an easy way. I tried to write it in very simple language and tried to use very less technical terms. In coming posts, I am going to explain more basic concepts with examples.
1 comment:
Like it. Moves at a fast clip. Non technical people need something to grasp the new world. Want to avoid branching out into a “deep” understanding of Java etc. but need to know what is going on ...
Post a Comment