Computer Science 101

Data Abstraction

Gregory M. Kapfhammer


flickr photo by "Cowboy" Ben Alman shared under a Creative Commons (BY-NC-ND) license

Color Scheme

Key Concept

Corresponding Diagram

In-Class Discussion

In-Class Activity

Details in the Textbook

Object-Oriented Design

Goals: robustness, adaptability, reusability

Principles: abstract, encapsulation, modularity

Terms: polymorphism, inheritance, encapsulation

Any questions about these key points?

Language constructs support these principles

See Figure 2.3 for a complex inheritance hierarchy

See Figure 2.4 for a simple inheritance hierarchy

See Figure 2.5 for another inheritance hierarchy

What is a numerical progression?

See Code Fragment 2.7

Interfaces and abstract classes

Establish a contract for an implementation

Defer implementation to another class

Exception Handling

What could go wrong?

File system problems

Network problems

Write a Java program that divides a variable by zero!

How to Handle?

Do not handle the exception

Handle the exception where it occurs

Handle the exception somewhere else in the program

What are the trade-offs of these solutions?

Uncaught exceptions

Caught Exceptions

How are exception types similar and different?

Try-Catch Statements

Casting and Generics

Why are generics important?

Let's investigate a method signature!

public static <T> void reverse(T[] data)

Nested Classes

Why are nested classes important?

Intuitively, a class within a class

Any questions about object-oriented design?