1 / 16

Abstraction in Object-Oriented Programming

Abstraction in Object-Oriented Programming. Procedural Abstraction. Procedural Abstractions organize instructions. Function Power Give me two numbers (base & exponent) I’ll return to you base exponent ??? Implementation ???. Data Abstraction. Data Abstractions organize data. StudentType.

orvalg
Download Presentation

Abstraction in Object-Oriented Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Abstraction in Object-Oriented Programming

  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. Queue Object Enqueue Is Full Data State Is Empty Dequeue Initialize Behavioral Abstraction • Behavioral Abstractions combine procedural and data abstractions.

  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. 1 3 5 2 4 R 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!

  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. An idea, a concept, an abstraction of the “big picture” It encapsulates the abstract behaviors and dataimplied by the thing being modeled. Abstract Data Types Queue Enqueue Is Full Data State Is Empty Dequeue Initialize

  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.

More Related