Posted by potty
on January 20, 2014 at 11:52 PM PST
Introduction to object-oriented programming concepts: class, objects, polymorphism, abstraction, inheritance.
Why do we need to program?
Technology is part of our life. The world is changing daily and everything is getting automated. Learn to program is the creative way we can take our ideas to the next level and express solutions to society. By designing programs, we learn several abilities like critical reading, analytical thinking and create synthesis. The programmer defines the problem, plans a solution, codes the program, test the proposal and documents the features. But we can't program all the solutions with the same method, that's why programming paradigms appears.
Overview of Programming Paradigms
According to Vasappanavara, a programming paradigm "it is the manner in which programming elements such as functions, objects and variables are exploited to produce the desired output". It is important to understand that programming paradigms are not programming languages.
The following are typical examples of programming paradigms (according to Bhave):
What is Object-oriented Programming (OOP)?
The object-oriented is a programming paradigm where the program logic and data are weaved. As stated by Phil Ballard, it is a way of conceptualizing a program's data into discrete "things" referred to as objects, each having its own properties and methods.
Let's see an example. Suppose your friend is a bank manager and he wants you to help improving their system. The first object you might design is the general-purpose
Account object has properties and methods. For each client your friend's bank have, you would have to create an
As follows the most important features of object-oriented programming:
- Encapsulation. Capability to hide data and instructions inside an object.
- Inheritance. Ability to create one object from another.
- Polymorphism. The design of new classes is based on a single class.
- Message Passing. It is the way objects communicate with each other.
- Garbage Collection. Automatic memory management that destroys objects that are no longer in use by the program.
As follows some benefits of using object-oriented programming:
- Re-usability. You can write a program using a previous developed code.
- Code Sharing. You are able to standardize the way your are programming with your colleagues.
- Rapid Modeling. You can prototype the classes and their interaction through a diagram.
As follows the disadvantages of using object-oriented programming:
- Size. Are larger than other programs, consuming more memory and disk space.
- Effort. Require a lot of work to create, including the diagramming on the planning phase and the coding on the execution phase.
Basic template that specifies the properties and behaviours of something (real life or abstract).
Particular instance of a class that responds consequently to events.
Characteristics of the class. Often called instance variables.
Algorithm associate to an class that represent a thing that the object does.
Class based on another class.
Process where the subclass gets the attributes and methods from its parent class.
Specific template that enforces certain attributes and methods of a class.
Namespace that organizes a set of related classes and interfaces.
Alert the application when there is a state change of the object.
- Vasappanavara, R. Object-oriented Programming Using C++ and Java. Chapter 1. Object-oriented Programming Basics. Section 1.3. Programming Paradigms. Pearson Education. India. May, 2011.
- Bhave, M. Object Oriented Programming with C++, Second Edition. Chapter 4. Object Orientation: An Introduction. Section 4.1. Programming Paradigms. Pearson Education. India. May, 2012.