+ All Categories
Home > Documents > CSC 205 Java Programming II

CSC 205 Java Programming II

Date post: 06-Jan-2016
Category:
Upload: marinel
View: 29 times
Download: 3 times
Share this document with a friend
Description:
CSC 205 Java Programming II. Abstract Data Type. Abstraction. The meaning of abstraction - PowerPoint PPT Presentation
Popular Tags:
12
CSC 205 Java Programming II Abstract Data Type
Transcript
Page 1: CSC 205  Java Programming II

CSC 205 Java Programming II

Abstract Data Type

Page 2: CSC 205  Java Programming II

Abstraction

The meaning of abstraction

Abstraction arises from a recognition of similarities between certain objects, situations, or processes in the real world, and the decision to concentrate upon these similarities and to ignore for the time being the differences

A definition by Grady BoochAn abstraction denotes the essential characteristics of an object that distinguish it from all other kinds of objects and thus provide crisply defined conceptual boundaries, relative to the perspective of the viewer

Page 3: CSC 205  Java Programming II

Abstraction

Page 4: CSC 205  Java Programming II

The Walls – abstraction barrier

An abstraction serves as an separation between an object’s behavior and its implementation – an abstraction barrier

It focuses on the outside view of an object and hide the implementation details

Deciding upon the right set of abstractions for a given domain is the central problem in OO design

Page 5: CSC 205  Java Programming II

The Walls – an example

The ice maker as an abstraction, has the following well-defined behaviors Output

Crushed ice Ice cubes Chilled water

Indicate Out-of-ice

Input Water

The ice maker in a client’s view –The ways how ice is made and howthe dispenser works is unknown

Page 6: CSC 205  Java Programming II

clientclient server

contract

request

Client-Server Contracts

A collaboration is a one-way interaction between two objects: one plays the client role, the other plays the server role

A C-S contract is defined by the set of request that a client can make of a server (in terms of public methods in Java)

Page 7: CSC 205  Java Programming II

Inside the Walls

Services defined in the contract is solely up to the server object Structural elements – data members Behavioral elements – methods

Java classes are good in implementing such abstractions

IceMaker

+chill()+crush()+cube()+isEmpty()+addWater()

Page 8: CSC 205  Java Programming II

Abstract Data Type

An ADT is an abstraction of a data type, with a collection of data, and a set of operations on that data

Typical operations an ADT needs to support Add data to a data collection Remove data from a data collection Inquiries about the data in the collection

Page 9: CSC 205  Java Programming II

What Is Not an ADT?

An ADT is not a data processor It’s not supposed to manipulated data So an abstraction such as the ice maker is not a

good example It takes in water, and outputs something different

Page 10: CSC 205  Java Programming II

Various ADTs

Linear ADTs Lists Queues Stacks

Trees Binary trees

Maps Dictionaries

Sets

Page 11: CSC 205  Java Programming II

The ADT List

Operations supported Create Check if empty Determine size Add items Remove items Retrieve items (at a given position)

Page 12: CSC 205  Java Programming II

A Sample Java Implementation

java.util.Vector


Recommended