Free Hosting

Welcome to object-oriented programming


All of the previous lessons up to this point have one thing in common — they have been non-object-oriented. Now that you have a basic handle on those concepts, we can proceed into object-oriented programming (OOP), where the real payoff is!
In traditional programming, programs are basically lists of instructions to the computer that define data and then work with that data. Data and the functions that work on that data are separate entities that are combined together to produce the desired result.
So what is object-oriented programming? As with so many things, it is perhaps understood most easily through use of an analogy. Take a look around you — everywhere you look are objects. Most objects have two major components to them: 1) A list of properties (eg. weight, color, size, texture, etc…), and 2) Some number of actions that either they can perform, or that can be performed on them (eg. being opened, having something poured into it, etc…). These two components are inseparable.
With traditional programming, the properties (data) and actions (functions) are separate entities, which means that traditional programming often does not provide a very intuitive representation of reality. We are intuitively used to thinking about things as objects, and expect to be able to perform actions with or on those objects.
Object-oriented programming (OOP) provides us with the ability to design “objects” that have both characteristics (sometimes called attributes, fields, or properties) and behaviors (methods or features), all tied together in one package. This allows programs to be written in a more modular fashion, which makes them easier to write and understand, and also provides a higher degree of code-reusability. Objects provide a more intuitive way to work with our data by allowing us to define how we interact with the objects, and how they interact with other objects. Object-oriented programming also brings several other useful concepts to the table: inheritance, encapsulation, abstraction, and polymorphism (language designers have a philosophy: never use a small word where a big one will do).
We will be covering all of these concepts in the upcoming tutorials over the next few chapters. It’s a lot of new material, but once you’ve been properly familiarized with OOP, you’ll never want to go back to traditional programming again.

0 comments:

Blogger Template by Clairvo