7.1. Object-Oriented Programming
Before you begin to learn Objective-C, you need to know a little bit about what it was designed to achieve. Object-oriented programming (OOP) has really caught on only over the last 15 years or so, but is now the de facto standard for all programming languages. Nearly all development these days takes place in the object-oriented style—even in non-OO languages like C!
So what is OOP? The main distinction between programming in an object-oriented language like Objective-C, and programming in a procedural language like C, is that data and functions that operate on that data are grouped together into entities called objects. An object has both data and behavior: the data are the variables belonging to the object, and the behavior is defined by the object's functions.
An object is actually a variable or instance of a particular class. A class defines what data and functions a particular type of object has. For example, a class called Person could declare that Person objects have a name and address, and that they have functions to create a new Person, delete an existing Person, and perform operations like changing a Person's address.
If you worked through the chapter on C programming, you realize by now that OOP has many similarities with the structured programming example you encountered in the simple address book program MyAddressBook. Indeed, structured programming with Abstract Data Types (ADTs) was a forerunner of OOP, and is still used today to ...
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.
Read now
Unlock full access