Skip to Main Content
Objective-C® For Dummies®
book

Objective-C® For Dummies®

by Neal Goldstein
October 2009
Beginner content levelBeginner
456 pages
8h 59m
English
For Dummies
Content preview from Objective-C® For Dummies®

Chapter 10. Basic Inheritance

In This Chapter

  • Understanding inheritance

  • Implementing inheritance

  • Understanding the connection between inheritance and polymorphism

In Chapter 9, you create a Transaction object and use a switch statement to manage more than one kind of transaction in a single array. The problem with that approach is that the switch statements can rapidly get very complicated, and a program with switch statements scattered throughout becomes difficult to extend and enhance.

Quite frankly, this kind of complex control structure is characteristic of the procedural program paradigm that I speak of in Chapter 3. Object-oriented programming and Objective-C do not "improve" this control structure as much as eliminate it as much as possible. The way this is done is by using one of those Objective-C's extensions to C — inherence to take advantage of polymorphism (which I explain in Chapter 3). As you find out as I lead you through implementing an inheritance-based class structure in this chapter, this greatly simplifies things, and you end up with a program that is a great deal easier to understand and extend (the two actually go hand in hand).

Note

Once you get into the rhythm of thinking this way, programming and making changes becomes more fun and less dreary. You introduce fewer bugs as you add functionality to your program, and your coding becomes completely focused on the new functionality instead of having to go back through everything you have done to see if you are about ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Objective-C

Objective-C

Jiva DeVoe
Cocoa in a Nutshell

Cocoa in a Nutshell

Michael Beam, James Duncan Davidson

Publisher Resources

ISBN: 9780470522752Purchase book