Welcome to Design Patterns

HFDP

Read HFDP online

1: Welcome to Design Patterns

TODO: Fill in HFDP_Chapter_1.md with notes for Chapter 1 of HFDP.

https://ucsb-cs56-pconrad.github.io/hfdp/HFDP_Chapter_1/

Chapter 1: Intro to Design Patterns

It started with a simple SimUDuck app

This page introduces the SimUDuck application. This is a silly example, like so many of those used in the Head First books, but since it forms the basis of the rest of the chapter, its important to at least suspend our disbelief and “go with it”. Try to understand the premise of what the SimUDuck application is trying to accomplish: namely, realistic simulation of a variety of kinds of ducks swimming and quacking.

But now we need the ducks to FLY

The key point here is that “some behavior about the class needs to change”. The idea of making the ducks fly is a shorthand in this silly example for something that happens in real-life all the time: some user requirement gets added, or something changes, and a component of the software has to be able to do something that it didn’t do before.

The essence of design patterns, as we’ll see, is designing the software in a way that makes it easier to make these changes—setting ourselves up for success—rather than making it difficult (setting ourselves up for failure.)

But something went horribly wrong…

Joe thinks about inheritance…

How about an interface?

What would you do if you were Joe?

The one constant in software development

Zeroing in on the problem…

Separating what changes from what stays the same

Designing the Duck Behaviors

Implementing the Duck Behaviors

Integrating the Duck Behavior

More integration…

Testing the Duck code

Setting behavior dynamically

The Big Picture on encapsulated behaviors

HAS-A can be better than IS-A

Speaking of Design Patterns…

Overheard at the local diner…

Overheard in the next cubicle…

The power of a shared pattern vocabulary

How do I use Design Patterns?

Tools for your Design Toolbox

https://ucsb-cs56-pconrad.github.io/hfdp/HFDP_Chapter_1/