lec02 - CSE 12 ADT's, OOP, and Java Abstraction and ADT's...

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

View Full Document Right Arrow Icon
01-1/74 Abstraction and ADT's The OO approach ADT specifications and Programming by Contract Code reuse through composition and inheritance Polymorphism and generic programming Java generic types Error handling with exceptions Software testing Unit testing with JUnit CSE 12 ADT's, OOP, and Java
Background image of page 1

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

View Full DocumentRight Arrow Icon
01-2/74 Abstraction (revisited) A tool to manage complexity: concentrate on the interface to a “thing”, while hiding its implementation details Applying the concept to data types leads to the idea of Abstract Data Types (ADT’s), which involve just the specification view… Recall the specification view of a type: no implementation details, just specification of values and operations
Background image of page 2
01-3/72 Checkpoint Abstraction is useful, but. .. Are there times when it would also be useful to know the implementation details of an ADT's operations or values?
Background image of page 3

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

View Full DocumentRight Arrow Icon
01-4/72 Abstraction by interface Any client (user) can make use of a List through its public interface (API) without knowledge of how the List is implemented.
Background image of page 4
01-5/72 Abstraction by interface The public interface (API) of List specifies everything a client needs to know to use a List. List insert(element) remove(element) find(element) isEmpty() public interface
Background image of page 5

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

View Full DocumentRight Arrow Icon
Abstraction: interface There are many possible implementations of any ADT. The implementation details are hidden from the user of the ADT, who can rely just on the ADT’s API. What does a user of a List need to know about it? The List API, not the List implementation.
Background image of page 6
01-7/72 Specifying an ADT When giving the specification view, you should specify these things: ADT name: The name of the data type. ADT description: A brief summary description of the type. ADT invariants: Assertions that must always be true of any instance of this type. ADT attributes: The state of an instance of the type, as observable by a client ADT operations: The behavior of an instance of the type, as observable by a client.
Background image of page 7

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

View Full DocumentRight Arrow Icon
01-8/72 Specifying operations of an ADT Specifying ADT operations is particularly important: these operations constitute the API, and are the primary way that users of the ADT interact with its instances. For each ADT operation, you should specify: responsibilities : A brief summary of what the operation does. pre-conditions : What must be true on entry to the operation if the operation is to execute successfully. This may include assumptions about the state of the object, assumptions about the parameters passed in, and so on. An operation's pre-conditions must be consistent with all of the ADT's invariants. post-conditions : What the operation guarantees to be true when it returns, if the pre-conditions were true when the operation was called. An operation's post-conditions must be consistent with all of the ADT’s invariants.
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/15/2011 for the course ECON 1 taught by Professor Aben during the Fall '07 term at City College of San Francisco.

Page1 / 74

lec02 - CSE 12 ADT's, OOP, and Java Abstraction and ADT's...

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

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