140 likes | 280 Views
Data Abstraction. Object-Oriented Analysis and Design The analysis and design methodology used on most large systems. Gather Requirements They provide: Perception of what the client expcets Description of what a solution must do They do not provide: Design details Implementation details
E N D
Object-Oriented Analysis and Design • The analysis and design methodology used on most large systems
Gather Requirements • They provide: • Perception of what the client expcets • Description of what a solution must do • They do not provide: • Design details • Implementation details • Problem is expressed in terms of relevant objects and how they interact with one another Oblect Oriented Analysis
Description of a high-level solution to the problem discovered during the analysis phase • Solution is expressed in terms of software objects and how they interact Object-Oriented Design
A collection of attributes • Data members: what do I know • A collection of behaviors • Methods (or functions): what can I do • Each object (specified as a class) • Has a single, well-defined task • If a class/object has too many responsibilities, it should be split into multiple classes What are Software Objects?
Encapsulation: Objects combine data and operations • Inheritance: Classes can inherit properties from another class • Polymorphism: Objects determine appropriate operations at run-time • CPSC 122: Encapsulation only OO Terms/Techniques
Operation Contracts • Documents how a method can be used and what it’s limitations are • Does not specify how operations are completed • Summarized in • Task: what the method does • Precondition: statement of the conditions that must exist at the beginning of the function • Postcondition: statement of the conditions at the end of the function
/* Task: Sorts and array Precondition: anArray is an array of num integers; num > 0. Postcondition: The integers in anArray are sorted */ Example
Abstraction separates the purpose of a module from its implementation • If you used sqrt within cmath, you made use of abstraction • Abstraction presents a public face of the object to the user. The private implementation is left to the developer Abstraction
Abstraction specifies a public view • It also implies a private view • In a nutshell • Your user doesn’t need to know how something is implemented to use it. • OO programming languages provide mechanisms to make implementation and data inaccessible to users • The Walls in the book’s title • User program on one side • Implementation on the other • Communication is through standard/principled channels: a slit in the wall • Prototype/declaration/header Data/Information Hiding
Abstract Data Type • Basically an object without inheritance and polymorphism • Collection of data and operations on the data. • Consider ADT Bag • Software that collects things • Software that operates on the collection ADTs: Before Objects
Do • How many items in bag • Is bag empty • Add item to bag • Remove item from bag • Remove everything from bag • How many times does a certain kind of item appear in the bag • Does the bag contain a specific object • Display all items in bag ADT Bag