ch13 - ObjectOrientedProgramming Chapter13...

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

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

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

View Full DocumentRight 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?)
Background 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.
Background image of page 3

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

View Full DocumentRight 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.
Background 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 …
Background image of page 5

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

View Full DocumentRight 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
Background 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
Background image of page 7

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

View Full DocumentRight Arrow Icon
A Stack Type in C Figure 13.2 stack.h header file to specify the  STACK data type.
Background 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
Background image of page 9

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

View Full DocumentRight 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.
Background image of page 10
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 . Achieved by packaging data and functions together 
Background image of page 11

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

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

This note was uploaded on 04/21/2010 for the course CS 424 taught by Professor Weisskopf during the Spring '10 term at University of Alabama - Huntsville.

Page1 / 50

ch13 - ObjectOrientedProgramming Chapter13...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online