Book Image

OpenLayers 2.10 Beginner's Guide

Book Image

OpenLayers 2.10 Beginner's Guide

Overview of this book

Table of Contents (18 chapters)
OpenLayers 2.10
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Behind the scenes—Object Oriented Programming (OOP)


Now, let's talk about how this stuff works from a more theoretical and technical level. OpenLayers employs Object Oriented Programming (OOP) techniques, meaning that to use with the library, we create objects from built in classes that OpenLayers provides.

What does this mean? You already are familiar with what classes and objects are, but you just may not know it. Think of the concepts of a class and object in terms of the parts of speech. For example, think of what the abstract idea of a noun means—a person, place, thing, or idea. Noun itself (the abstract idea) is a class. But the actual, concrete words that qualify as a noun are objects.

Interaction happens with objects

Ironman and Batman are two separate words (or, in terms of OOP, two objects), but they belong to the same noun class. A class is primarily used to generate objects; we interact with objects. Consider these two sentences:

"Noun was in a fight with noun."

"Ironman was in a fight with Batman."

Now, the second sentence is more of an actual sentence. We use the words Ironman and Batman in the sentence (which are objects; they are instances of the noun class). We don't use noun (a class) in the sentence, because interacting with a class like this doesn't make much sense. This is one of the important concepts of OOP—we interact with objects, and we generate objects through classes.

MadLibs

Madlibs, for those unfamiliar with it, is a game where you are given text with some missing words. The point is to come up with words to fill in the blanks, but each blank can only contain a certain type of word (noun, adjective, verb, and so on). The type of word is a class and the actual word you insert is an object.