What's the difference between an Algorithm and a Design Pattern

Peter Turner picture Peter Turner · Feb 17, 2009 · Viewed 14.4k times · Source

I was searching for "Undo/Redo algorithms" and found something marked as a duplicate, but the duplicate was a request for a "Undo Design Pattern". I'd really like an algorithm for this. I don't think I necessarily need a design pattern.

Is there a fundamental difference between "Design Pattern" and "Algorithm" or is it OK that someone uses the two interchangeably?

I'll hang up and take my answer off the air.

Ok, forgive me for thinking design patterns were just abstractions of algorithms. Here's a little table of my findings from the answers which were all very good.

   Design Pattern |    Algorithm
------------------|----------------
Abstract          | Concrete
Control Structure | Set of Actions    
Template          | Implementation
Flexible          | Deterministic
Blueprint         | Recipe

Answer

Steven A. Lowe picture Steven A. Lowe · Feb 17, 2009

An algorithm is like a recipe: a step-by-step process for performing some activity.

A design pattern is like a blueprint: an structured collection of objects and associations and actions to accomplish some goal.