Chapter 6. OOP
Object-oriented programming (OOP) is sometimes thought of as a problem-solving technique—a way of organizing your code into small, specific, easily digestible chunks (objects) to make project or application development more manageable. These objects are typically designed to be as self-contained as possible, but are also usually designed to play well with other objects. Choosing OOP as a programming methodology is a decision that is sometimes fairly obvious, such as when working with large projects or with a team of collaborating programmers. At other times, however, adopting OOP as a development strategy can be less obvious, and even debated.
The goal of this chapter is to give you a high-level view of object-oriented principles, as well as supporting examples, to help prepare you to make these decisions on a project-by-project basis. Each subsequent chapter in this book will continue to focus on syntax in concise, timeline-based exercises, but also make increasing use of classes. Ultimately, we hope you will continue your learning using the book’s companion web site, where a cumulative project will collect much of what you’ve created along the way into a “lab” of experiments. The larger project will be OOP-based but also will contain exercises that you create using procedural techniques, exposing you to both authoring paradigms.
Knowing when to opt for an object-oriented model depends largely on understanding the benefits of OOP, among them:
Classes. Classes are collections ...
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