Presentation is loading. Please wait.

Presentation is loading. Please wait.

Abstraction and Objects

Similar presentations


Presentation on theme: "Abstraction and Objects"— Presentation transcript:

1 Abstraction and Objects

2 Procedural Abstraction
Procedural Abstractions organize instructions. Function Power Give me two numbers (base & exponent) I’ll return to you baseexponent ??? Implementation ???

3 Data Abstraction Data Abstractions organize data. StudentType
Name (string) GPA (num) Letter Grade (char) Student Number (num)

4 Behavioral Abstraction
Behavioral Abstractions combine procedural and data abstractions. Data State Enqueue Is Full Is Empty Dequeue Initialize Queue Object

5 The Object-Oriented Paradigm
Instances of behavioral abstractions are known as objects. Objects have a clear interface by which they send and receive messages (communicate). OO is a design and approach issue. Just because a language offers object-oriented features doesn’t mean you’re doing OO programming.

6 Information Hiding Information Hiding means that the user has enough information to use the interface, and no more Example: Stick shift We don’t care about the inner workings... We just want to get the car going! 1 2 3 4 5 R

7 Encapsulation Encapsulation is the grouping of related things together within some structure Item 1 Item 2 Item3

8 Encapsulation via Algorithms
Algorithms encapsulate modules, data, and instructions. Algorithm Procedure Instructions Function Data

9 Encapsulating Instructions
Modules encapsulate instructions. Procedure/Function Instructions Instructions Module call Instructions

10 Encapsulating Data Records allow us to do this with data Record
Field 1 Field 2 Record

11 Revisiting the Question “Where is the Queue?”
Notice we still have no way of identifying the idea we’re discussing… The Queue is still in the “ether.” We’d like to encapsulate the data (regardless of it’s actual representation) with the behavior (modules). Once we do this, we’ve got a logical entity to which we can point and say, “there it is!”

12 Encapsulating Data with Methods
Abstract data types (ADTs) allow us to encapsulate logically related data and modules Queue Enqueue Data Dequeue

13 Abstract Data Types An idea, a concept, an abstraction of the “big picture” It encapsulates the abstract behaviors and data implied by the thing being modeled. Data State Enqueue Is Full Is Empty Dequeue Initialize Queue

14 Achieving Behavioral Abstraction
Abstract data types (ADTs) are concepts. We require some way to implement these common abstractions so we can write them once, verify that they are correct, and reuse them. This would save us from having to re-do work. For example, every time we create a queue we did: List_Node definesa ... q_front isoftype ... q_tail isoftype ... procedure Enqueue(...) procedure Dequeue(...) We need an algorithmic construct that will allow us to bundle these things together… the class.

15 OO Summary Behavioral abstraction combines data abstraction with procedural abstraction. The object-oriented paradigm focuses on the interaction and manipulation of objects. An Abstract Data Type (ADT) allows us to think of what we’re representing as a thing regardless of it’s actual implementation.

16 Summary: Classes and Objects
Java like many OO languages has a way of describing an abstract data type (that is something encapsulating both data and methods for manipulating the data) This structure is known as a class It is sort of like a record which contains procedures in addition to the data Thus it is a definition of a type When we actually “make” an instance of one of these classes we get an object.

17


Download ppt "Abstraction and Objects"

Similar presentations


Ads by Google