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 11. Encapsulating Objects

In This Chapter

  • Understanding the Model-View-Controller pattern

  • The role of interfaces

  • How composite objects work

  • Factoring your code to implement Model-View-Controller

Using encapsulation enables you to safely tuck data behind an object's walls. You can keep the data safe and reduce the dependencies of other parts of your program on what the data is and how it is structured.

Encapsulation is also useful when you apply it to application functionality. When you limit what your objects know about other objects in your application, changing objects or their functionality becomes much easier because it reduces the impact of those changes on the rest of your application.

In this chapter, I'll show you a way to design, or architect, your application that limits the knowledge that objects have of other objects.

Getting to Know the Model-View-Controller (MVC) Pattern

The Cocoa framework you'll use on the Mac is designed around certain programming paradigms, known as design patterns — a commonly used template that gives you a consistent way to get a particular task done.

While you'll need to be comfortable with several design patterns in Cocoa, there is one that implements the kind of object encapsulation that reduces the impact of changes to an application — the Model-View-Controller (MVC) design pattern. This design pattern is not unique to Cocoa — a version of it has been in use since the early days of Smalltalk (which the Objective-C extensions to the C language ...

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