Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

9. Objects

Chapter 9. Objects

Object-oriented programming (OOP) is a different way to think about your programs. Although the term "object-oriented programming" may sound intimidating, there's good news: you've been working with objects since Chapter 6, when you started using PImage, PFont, String, and PShape. Unlike the primitive data types boolean, int, and float, which can store only one value, an object can store many. But that's only a part of the story. Objects are also a way to group variables with related functions. Because you already know how to work with variables and functions, objects simply combine what you've already learned into a more understandable package.

Objects are important, because they break up ideas into smaller building blocks. This mirrors the natural world where, for instance, organs are made of tissue, tissue is made of cells, and so on. Similarly, as your code becomes more complicated, you must think in terms of smaller structures that form more complicated ones. It's easier to write and maintain smaller, understandable pieces of code that work together than it is to write one large piece of code that does everything at once.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial