Chapter 11. Examining Object-Oriented Programming

In This Chapter

  • Making nachos

  • Reviewing object-oriented programming

  • Introducing abstraction and classification

  • Discovering why object-oriented programming is important

What, exactly, is object-oriented programming? Object-oriented programming, or OOP as those in the know prefer to call it, relies on two principles you learned before you ever got out of Pampers: abstraction and classification. To explain, let me tell you a little story.

Abstracting Microwave Ovens

Sometimes when my son and I are watching football (which only happens when my wife can't find the switcher), I whip up a terribly unhealthy batch of nachos. I dump some chips on a plate, throw on some beans, cheese, and lots of jalapeños, and nuke the whole mess in the microwave oven for five minutes. To use my microwave, I open the door, throw the stuff in, and punch a few buttons. After a few minutes, the nachos are done.

Now think for a minute about all the things I don't do to use my microwave:

  • I don't rewire or change anything inside the microwave to get it to work. The microwave has an interface — the front panel with all the buttons and the little time display — that lets me do everything I need to do.

  • I don't have to reprogram the software used to drive the little processor inside my microwave, even if I cooked a different dish the last time I used the microwave.

  • I don't look inside my microwave's case.

  • Even if I were a microwave designer and knew all about the inner workings ...

Get C++ For Dummies®, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.