Chapter 3. The Object in Objective-C

In This Chapter

  • Recognizing the importance of modules

  • Getting a handle on objects

  • Seeing encapsulation and polymorphism in action

  • Refining the idea of "reusable code"

In Chapter 2, you get your first taste of programming (all right, enough with the food), and over the next 15 chapters, I show you everything you need to know to write computer programs. While you may think that's pretty cool, you shouldn't be satisfied with that alone. Your goal shouldn't be to simply be able to write programs using Objective-C; your goal should be to write good programs using Objective-C.

So what makes a good program? Well, a blinding flash of the obvious answer is one that meets the needs of the user. While that is true, it is only part of the answer. What also makes a program good is how easy it is to make changes to it.

I want to use the example I give you in Chapter 1 — a computer program that tracks my expense when I travel. It keeps track of my budget and converts foreign currency charges into dollars.

As I develop this program, I am going to have to make changes to it for three reasons.

  • I'll want to add new functionality. For example, starting out, the program will work with cash and credit card transactions. I'll get that up and running, and then eventually I'll want to be able to add ATM transactions, and also track my hotel and plane reservations. I will want to be able to do this without having to completely rewrite the program. In fact, I would like to be able ...

Get Objective-C® For Dummies® 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.