Stephenson College DP 96 1 Object-Orientation by Derek Peacock
Stephenson College DP 96 2 Types of Objects a Tangible things ` Cars, Cards, Books a Roles ` Employer, Teacher, Student a Incidents ` Flight, Transactions
Stephenson College DP 96 3 Types of Objects cont... a Interactions ` Electrical circuit, a contract a Specifications ` Architectural Design ` Engineering blueprint
Stephenson College DP 96 4 Objects in Programming a Direct representation of the application ` Graphical Playing Cards ` Documents ` Accounts a Artefact of Implementation ` Card Deck Unit ` stacks, queues
Stephenson College DP 96 5 What are Objects? a Attributes, States a Methods, Behaviour a Composed of other objects
Stephenson College DP 96 6 Program Objects Object = (private) Data + (public) Processes Object Name Public Processes Private Data
Stephenson College DP 96 7 Encapsulation a Data & Processes linked a Public interface a Information is hidden a private data a private internal processes Bank Account Account number account holder current balance get current balance make deposit make withdrawal
Stephenson College DP 96 8 Traditional Modularity Process Driven a Functional Decomposition a Data structured to suite the process a code re-use difficult Data Driven a Data Decomposition a Process constrained by the structure of data a code re-use difficult
Stephenson College DP 96 9 Object Oriented Modularity a Data & Process tightly bound together (encapsulated) a Internal data and processes hidden a Public interface can remain fixed while internal workings are changed a Can be extended without altering original code
Stephenson College DP ‘Good’ Modules a Reusability a Extensibility a Decomposability a Composability a Understandability a Continuity a Protection Software components New components from old breaking a system down building a system up easy to understand the part small changes lead to small effects errors confined to module
Stephenson College DP Features of OOP a Encapsulation/Abstraction a Inheritance a Polymorphism a Aggregation
Stephenson College DP Encapsulation/Abstraction a Abstraction is used to represent essential features of behaviours and states abstract data typeclass a Behaviours & States encapsulated into an abstract data type or class a Internal States not directly accessible a Changes to internal implementation do not effect external interface
Stephenson College DP Inheritance a One Class can inherit the characteristics of another class. ` One class can be a “Kind of” other class a kind of ` a text window is a kind of window a A classification hierarchy shows the inheritance relationships between classes
Stephenson College DP Polymorphism a Different objects can respond to the same message in different ways e.g. ` Square.Draw ` Circle.Draw a At runtime we might not know what object is present but for example Object.Draw will draw whatever object is available
Stephenson College DP Aggregation a Objects can be aggregated into new relationships a Objects of one class can be composed of objects of another class is a part of ` Object A is a part of Object B is a part of ` Engine is a part of Car
Stephenson College DP Comparing Approaches Procedural a Data Type a Variable a Function/Procedure Object-Oriented a Abstract Data Type or Class a Object/Instance a Method/Operation