16 OOP - Data Abstraction and Object- oriented Programming...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: Data Abstraction and Object- oriented Programming Scott Chapter 9 Control or process abstraction is a very old idea (subroutines!), though few languages provide it in a truly general form (Scheme comes close) Data abstraction is somewhat newer, though its roots can be found in Simula67 An Abstract Data Type is one that is defined in terms of the operations that it supports (i.e., that can be performed upon it) rather than in terms of its structure or implementation Why abstractions? easier to think about - hide what doesn't matter protection - prevent access to things you shouldn't see plug compatibility replacement of pieces, often without recompilation, definitely without rewriting libraries division of labor in software projects We talked about data abstraction some back in the unit on naming and scoping Recall that we traced the historical development of abstraction mechanisms Static set of global variables Basic Local variables Fortran, Algol 60, Pascal Statics Fortran, Algol 60 Modules Mesa, Modula-2 Ada 83 Module types Euclid Objects Simula, Smalltalk, C++, Eiffel, Oberon, Module-3, Ada95, C#,. Global variable lifetime spans program execution Local variables and nested scopes lifetime spans subroutine, and subroutines themselves can be local Statics allow a single subroutine to retain values from one invocation to the next, while hiding the name in-between Modules allow a collection of subroutines to share some statics, still with hiding If you want to build an abstract data type, though, you have to make the module a manager Module types allow instantiation of multiple instances Classes allow definition of families of related abstractions Recall Module as Manager style (In the coroutine example, Buffer module was not a manager, however, the module defining SIGNALS, was) MODULE BufferManager Buffer = POINTER to BufferDesc BufferDesc = RECORD ..END void init( Buffer: b ) . END init void put( Buffer: b , itemType x) . END put itemType get( Buffer: b ) .END get END Oberon: modules + type extensions maxBuffer = POINTER TO maxBuffeDesc; maxBufferDesc = RECORD (BufferDesc) int max END void init(maxBuffer: b); BEGIN BufferManager.init(b); b^.max = 0 END init; void put(maxBuffer: b, itemType x) BufferManager.put(b,x); b^.max := .. END put Oberon: modules + type extensions maxBuffer = POINTER TO maxBuffeDesc; maxBufferDesc = RECORD (BufferDesc) int max END void init(maxBuffer: b); BEGIN BufferManager.init(b); b^.max = 0 END init; void put(maxBuffer: b, itemType x) BufferManager.put(b,x); b^.max := .. END put This record extends BufferDesc by adding a new field, max Oberon: modules + type extensions maxBuffer = POINTER TO maxBuffeDesc; maxBufferDesc = RECORD (BufferDesc) int max END void init( maxBuffer: b ); BEGIN BufferManager.init(b); b^.max = 0 END init; void put( maxBuffer: b , itemType x) BufferManager.put( b ,x); b^.max := .....
View Full Document

This note was uploaded on 12/09/2009 for the course COP 5555 taught by Professor Staff during the Fall '08 term at University of Florida.

Page1 / 64

16 OOP - Data Abstraction and Object- oriented Programming...

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