ch13 - Chapter13 13.1:AbstractDataTypes...

Info icon This preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
Object Oriented Programming Chapter 13
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
13.1: Abstract Data Types Imperative program design is based on  functional decomposition , which systematically  refines the problem into smaller and smaller  parts until the functions are small enough to  represent in primitive language statements. Procedural  or  functional abstraction:    programmers think about the program in terms of  function interfaces and functionality (what does it  do?)
Image of page 2
Data Abstraction Extends the idea of procedural  abstraction to the data Abstract data type: a set of values, and  the operations that can be performed on  them.
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Encapsulation - Definition Encapsulation is a mechanism which  allows logically related constants, types,  variables, methods, and so on, to be  grouped into a new entity.   Encapsulation mechanisms limit the  scope and visibility of data and  functions.  Examples: procedure,  packages, classes.
Image of page 4
History Today, OO programming is the  preferred way to implement  encapsulation. Objects aren’t new – Simula 67,  Smalltalk-76 and Smalltalk-80. Other methods include …
Image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
C: (13.2-13.3) Header file +  implementation file Modula 2: Modules – definition and  implementation Ada: (13.4-13.5) Package – definition  and implementation
Image of page 6
Abstract Stack Designs/Fig  13.2 Figure 13.2, 13.3: primitive version of  ADT Encapsulates data and operations for an  integer stack Linked structure, composed of  value/pointer nodes Header + implementation files. Can’t generalize to other data types
Image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
A Stack Type in C Figure 13.2 stack.h header file to specify the  STACK data type.
Image of page 8
Figure 13.3 – Implementation  Implementation file shows typical stack  functions: empty, newstack, pop, push, top Any program that includes the header  can declare variables of type STACK  and use the functions in the  implementation file
Image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Independent Compilation  ADT Now we have a stack data type and a way to  dynamically declare stack variables, but… There’s no way to prevent the client from bypassing  the defined stack operations to directly access a stack  variable; e.g. to search the stack for a particular value There’s no way to generalize to other data types Better: force stack access to be  only  through the  interface (defined stack functions).  No inheritance, no encapsulation.
Image of page 10
Objectives of Data Abstraction Prevent  public access  to the underlying ADT  representation and provide a  public interface  to the ADT through  its operations (functions) and prevent any other  access; i.e.,  i.e., provide  information hiding .
Image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern