Object-Oriented programming is one of programming paradigms based on "objects" just like its name. What does it mean by 'based on objects'? How do we program this?
The concept of OPP(Object-Oriented Programming) seemed vague. Ok, I got the 'Object' part. Probably related to the using objects. But what does that mean? How do I use it? Just the taking the lecture was not enough for me to understand whole concept of OOP, so I studied about OOP further.
So, yes, Object-Oriented Programming(OPP) uses objects to program. The objects are data structure that contains data and it's also called 'attributes'. In the computer program using OOP, it is constructed on objects and these objects are interact with each other. For example, we have learned how to write classes. This is one way to design object-oriented program.
When I design a class, I initialize objects according to the purpose of codes I am writing. Then, I will probably add more methods that uses objects I initialized to get other result for a class. Like this, each objects are related to make computer program work. As I practice labs and exercises, I learned that using the objects to design program requires well-organized plan ahead what I want to write, proper purpose of classes and right contents in those classes.
A messy plan leads the result nowhere. It is hard to build the entire class and often hard to decide what to write for each methods or even what to initialize for a class. When the plan is well-organized and solid, it is easy to proceed to write. Having a plan also saves lots of time since it gives me a direction to next step. Just like we have a recipe for writing a function, organizing plan is good way to start.
An excellent, motivating plan without specific purposes of class, however, will be like poutine without gravy. One class should contain objects and functions that are relative to class docstiring. If the class doesn't do what is supposed to do, it will create confusion to users and it will be hard to make connect to other classes. Setting the specific purpose of a class and implementing proper methods are absolutely important to OPP.
In OPP, the following concepts are included as well:
- Classes of objects
- Instances of classes
- Methods acting on objects
- Message passing
- Abstraction
Not only is there Object-Oriented Programming for paradigms, also there are many other ways to design program. I only started to learn OOP, but there are so much to learn in OOP. So far, this is my understanding of OOP.
<Further study for OOP and other paradigms, I leave the Wikipedia link>
http://en.wikipedia.org/wiki/Object-oriented_programming
No comments:
Post a Comment