13.07.2015 Views

Beginning Objective-C pdf - EBook Free Download

Beginning Objective-C pdf - EBook Free Download

Beginning Objective-C pdf - EBook Free Download

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 2Object-Oriented ProgrammingObject-oriented programming is not new; today it’s probably the most widely used programmingparadigm on the planet. Its history goes back to the late 1950s and early 60s with the first useof classes and instances in the Simula 67 language. This concept was then expanded upon atXerox PARC in the 1970s with the creation of the Smalltalk language, which introduced the termobject-oriented programming to describe the pervasive use of objects and messages throughoutthe system; everything in Smalltalk was an object, even constant scalar values such as “62.”<strong>Objective</strong>-C was created in the 1980s as a means to merge the object-oriented approach (andsome of the syntax) of Smalltalk with the imperative programming of C.This chapter will teach you about the fundamentals of object-oriented programming and willintroduce you to the means in which the <strong>Objective</strong>-C language implements OOP. By the end ofthe chapter you should be familiar with all the relevant terminology and concepts necessary towork through the remainder of this book, as well as any other text on the <strong>Objective</strong>-C language.Objects: Classes and InstancesIn iterative programming languages, sequences of instructions are broken into methodsto provide a form of encapsulation of those instructions. Programmers further break downcollections of functions into separate files or libraries, providing interfaces via header files thatother groups of methods can use. Object-oriented programming (or OOP) takes this a stepfurther by providing a means of encapsulating data along with associated methods and giving afirst-class language construct to define that encapsulation.The reasoning behind the encapsulation of data is a fairly simple one: non-OOP programs,having no means to encapsulate data beyond explicitly passing that data around betweenmany functions, often place some of that data at global scope, making it accessible from(almost) anywhere. This leads to problems as the non-OOP program grows in size, leaving theprogrammer to try and prevent simultaneous access to these shared resources because notdoing so could easily lead to bugs with quite disastrous effects.23www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!