Algorithms and OOD (CSC 207 2014F) : Outlines

# Outline 54: Patterns of Object and Algorithm Design

Held: Tuesday, 9 December 2014

Summary

We step back and think about some general design princples we've learned this semester.

Related Pages

Overview

• Minimizing stamps, continued.
• Algorithm design.
• Data-structure design.
• Object design.
• Code design.

• Sit wherever you'd like.
• Exam signup sheet to be available tomorrow.
• I may have to reschedule some meetings because of a hearing.
• There's a Sam review session on Thursday, but it will probably just be a half session.
• Do you want a Mira session on Sunday?
• I can't do anything about MathLAN problems. Sorry.

### Upcoming Work

• Exam 2 due Thursday night.
• No more lab writeups!

### Extra Credit

• Inside Grinnell Thursday the 11th at noon in JRC 101: Grinnell's Endowment: What Can and Can't it Do?

#### Peer Support

• Ajuna's Radio show Mondays at 8pm. Listen to African music.
• Charlie's Friday Night "War in Animated Film" ExCo. (maybe)

## Minimizing Stamps, Continued

• Let's try to fill in the details of the exhaustive solution.
• What information might be useful to store?
• How does that help us compute a solution iteratively?

## Algorithm Design

• You are faced with a new algorithmic problem. How do you approach solving it?
• And what are common patterns of algorithms?
• We'll take a few minutes for you to talk amongst yourselves, and then we'll see what you've come up with.

• What are Sam's three questions for ADT design?

## Data Structure Design

• What are Sam's three questions for DS design?

## Object Design

• That is, what are common patterns of design.
• Here's one: The singleton. It's a class in which we want only one object.
• Take a few minutes to talk to your friends about other common patterns of design.
• A few that we've used
• Adapter - Convert an object to meet a different interface
• Decorator - Extend methods in another class, but meet the same interface.
• Delegate - Ask another object to do most of the work.
• Factory - A way to pass around constructors.