Chapter 1
Introduction......................................................................1
1.1 Examples..............................................................2
1.2 Object-Oriented Software Development .................................2
1.2.1 At the Top of Your Game.............................................3
1.2.2 Personal Development................................................3
1.2.3 Wicked Problems.....................................................5
1.2.4 Extreme Programming.................................................6
1.2.5 MATLAB, Object-Oriented Programming, and You .......................8
1.3 Attributes, Behavior, Objects, and Classes ...........................9
1.3.1 From MATLAB Heavyweight to Object-Oriented Thinker .................9
1.3.2 Object-Oriented Design..............................................10
1.3.3 Why Use Objects?....................................................11
1.3.4 A Quality Focus ....................................................12
1.3.4.1 Reliability.......................................................12
1.3.4.2 Reusability ......................................................13
1.3.4.3 Extendibility.....................................................14
1.4 Summary...............................................................15
PART 1
Group of Eight ........................................................ 17
Chapter 2
Meeting MATLAB’s Requirements ...................................................19
2.1 Variables, Types, Classes, and Objects ...............................19
2.2 What Is a MATLAB Class? ..............................................21
2.2.1 Example: Class Requirements........................................21
2.2.1.1 Class Directory ..................................................22
2.2.1.2 Constructor.......................................................22
2.2.1.3 The Test Drive ...................................................24
2.3 Summary...............................................................26
2.4 Independent Investigations ...........................................27
Chapter 3
Member Variables and Member Functions ............................................29
3.1 Members ..............................................................29
3.2 Accessors and Mutators ...............................................30
3.2.1 A Short Side Trip to Examine Encapsulation .........................31
3.2.1.1 cShape Variables .................................................32
3.2.2 cShape Members .....................................................33
3.2.2.1 cShape Private Member Variables...................................33
3.2.2.2 cShape Public Interface ..........................................34
3.2.3 A Short Side Trip to Examine Function Search Priority ..............36
3.2.4 Example Code: Accessors and Mutators, Round 1 ......................37
3.2.4.1 Constructor.......................................................37
3.2.4.2 Accessors ........................................................37
3.2.4.3 Mutators ........................................................38
3.2.4.4 Combining an Accessor and a Mutator...............................39
3.2.4.5 Member Functions..................................................40
3.2.5 Standardization ....................................................40
3.3 The Test Drive .......................................................41
3.4 Summary...............................................................42
3.5 Independent Investigations ...........................................43
Chapter 4
Changing the Rules … in Appearance Only .........................................45
4.1 A Special Accessor and a Special Mutator .............................45
4.1.1 A Short Side Trip to Examine Overloading ...........................45
4.1.1.1 Superiorto and Inferiorto ........................................47
4.1.1.2 The Built-In Function.............................................48
4.1.2 Overloading the Operators subsref and subsasgn.....................48
4.1.2.1 Dot-Reference Indexing............................................50
4.1.2.2 subsref Dot-Reference, Attempt 1..................................51
4.1.2.3 A New Interface Definition .......................................52
4.1.2.4 subsref Dot-Reference, Attempt 2: Separating Public and
Private Variables ........................................................53
4.1.2.5 subsref Dot-Reference, Attempt 3: Beyond One-to-One,
Public-to-Private ........................................................53
4.1.2.6 subsref Dot-Reference, Attempt 4: Multiple Indexing Levels .......55
4.1.2.7 subsref Dot-Reference, Attempt 5: Operator Conversion Anomaly.....57
4.1.2.8 subsasgn Dot-Reference ...........................................59
4.1.2.9 Array-Reference Indexing .........................................62
4.1.2.10 subsref Array-Reference .........................................63
4.1.2.11 subsasgn Array-Reference ........................................64
4.1.2.12 Cell-Reference Indexing..........................................65
4.1.3 Initial Solution for subsref.m .....................................66
4.1.4 Initial Solution for subsasgn.m ....................................68
4.1.5 Operator Overload, mtimes ..........................................69
4.2 The Test Drive .......................................................70
4.2.1 subsasgn Test Drive.................................................70
4.2.2 subsref Test Drive..................................................72
4.3 Summary...............................................................74
4.4 Independent Investigations ...........................................75 |