{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Chapter18 - CHAPTER Object-Oriented Programming Chapter...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter Objectives This chapter discusses the object-oriented paradigm, including: Object-oriented programming (OOP) in general How MATLAB implements OOP This chapter is not intended as a full treatment of the art and science of object-oriented design and object-oriented programming (OOP). Rather, it presents some basic definitions of terms used in OOP and the implementation in MATLAB of some simple constructs. Subsequent chapters will extend these ideas to illustrate how dynamic data structures may be constructed and manipulated using OOP. Object-Oriented Programming C H A P T E R 1 8 18.1 Object-Oriented Programming 18.1.1 OO Background 18.1.2 Definitions 18.1.3 Concepts 18.1.4 MATLAB Observations 18.2 Categories of Classes 18.2.1 Modeling Physical Things 18.2.2 Modeling Collections 18.2.3 Objects within Collections 18.3 MATLAB Implementation 18.3.1 MATLAB Classes 18.3.2 MATLAB Objects 18.3.3 MATLAB Attributes 18.3.4 MATLAB Methods 18.3.5 Encapsulation in MATLAB Classes 18.3.6 Inheritance in MATLAB Classes 18.3.7 MATLAB Parent Classes 18.3.8 MATLAB Child Classes 18.3.9 Polymorphism in MATLAB 18.4 Example—Modeling Bank Accounts 18.4.1 The Base Class 18.4.2 Inheritance by Extension 18.4.3 Inheritance by Redefinition 18.5 Practical Example— Vehicle Modeling 18.5.1 A Vehicle Hierarchy 18.5.2 The Containment Relationship 469
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
470 Chapter 18 Object-Oriented Programming 18.1 Object-Oriented Programming In Chapters 1–17 we saw MATLAB as a means for manipulating arrays sometimes in the guise of vectors or matrices, character strings, or cell arrays. Furthermore, the manipulation performed was conducted by writing scripts that sometimes call functions—either the functions built into MATLAB or functions we create ourselves. This type of programming is referred to as being in the procedural paradigm—functions and scripts as a form of procedure. This chapter considers a different paradigm altogether—the object- oriented (OO) paradigm. In this programming style, we still begin with a script, but the scripts that we write will usually create and interact with objects rather than arrays . 18.1.1 OO Background Languages that express the essential elements of the OO paradigm have been around since the 1960s when Simula was first developed. However, in the 1980s and 1990s, as massive software projects and especially graphical user interfaces (GUIs) became common, OO emerged as the paradigm of choice for designing and developing large software systems. Major software systems (like the various releases of Microsoft Windows) faced enormous design and integration challenges that could not be met by conventional programming practices. They needed language-imposed management of the interaction between large and small collections of programs and data. A secondary requirement in efficiently developing large software systems is the ability to reuse core software modules without rewriting their entire contents. OO principles allow core modules to be reused in three ways: Reused intact, because the definitions of how to use them are precisely recorded
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}