Design Patterns in the Wild Patterns in Apache Tomcat - Courses
Design Patterns in the Wild Patterns in Apache Tomcat - Courses
Design Patterns in the Wild Patterns in Apache Tomcat - Courses
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
View Source:<br />
<strong>Design</strong> <strong>Patterns</strong><br />
<strong>in</strong> <strong>the</strong> <strong>Wild</strong><br />
<strong>Patterns</strong> <strong>in</strong><br />
<strong>Apache</strong> <strong>Tomcat</strong><br />
© Ross Orr<br />
Ashw<strong>in</strong> J Ma<strong>the</strong>w Spr<strong>in</strong>g 2008<br />
School of Information, UC Berkeley
<strong>Patterns</strong> for Today<br />
●<br />
●<br />
●<br />
●<br />
Command<br />
Strategy<br />
Intercept<strong>in</strong>g Filter<br />
Visitor<br />
Ashw<strong>in</strong> J Ma<strong>the</strong>w Spr<strong>in</strong>g 2008<br />
School of Information, UC Berkeley
Ashw<strong>in</strong> J Ma<strong>the</strong>w Spr<strong>in</strong>g 2008<br />
School of Information, UC Berkeley<br />
Command
Ashw<strong>in</strong> J Ma<strong>the</strong>w Spr<strong>in</strong>g 2008<br />
School of Information, UC Berkeley<br />
Rules as Commands
Us<strong>in</strong>g Command<br />
●<br />
●<br />
●<br />
Decouple <strong>in</strong>voker of an operation from<br />
command object perform<strong>in</strong>g operation<br />
Invoker doesn't need to know what command<br />
does<br />
Command may carry <strong>in</strong>ternal state<br />
Ashw<strong>in</strong> J Ma<strong>the</strong>w Spr<strong>in</strong>g 2008<br />
School of Information, UC Berkeley
Ashw<strong>in</strong> J Ma<strong>the</strong>w Spr<strong>in</strong>g 2008<br />
School of Information, UC Berkeley<br />
Strategy
ProtocolHandler as Strategy<br />
Ashw<strong>in</strong> J Ma<strong>the</strong>w Spr<strong>in</strong>g 2008<br />
School of Information, UC Berkeley
Us<strong>in</strong>g Strategy<br />
●<br />
●<br />
●<br />
Client operates on <strong>in</strong>terface or abstract class<br />
Implementation varies <strong>in</strong>dependent of client<br />
Strategies are “pluggable”<br />
Ashw<strong>in</strong> J Ma<strong>the</strong>w Spr<strong>in</strong>g 2008<br />
School of Information, UC Berkeley
Ashw<strong>in</strong> J Ma<strong>the</strong>w Spr<strong>in</strong>g 2008<br />
School of Information, UC Berkeley<br />
Intercept<strong>in</strong>g Filter
ApplicationFilterCha<strong>in</strong> as<br />
Intercept<strong>in</strong>g Filter<br />
Ashw<strong>in</strong> J Ma<strong>the</strong>w Spr<strong>in</strong>g 2008<br />
School of Information, UC Berkeley
Us<strong>in</strong>g Intercept<strong>in</strong>g Filter<br />
●<br />
●<br />
●<br />
●<br />
●<br />
Filter cha<strong>in</strong> “<strong>in</strong>tercepts” all requests<br />
Filters are loosely coupled<br />
Filter Manager oversees <strong>in</strong>vocations of Filters<br />
Filters may choose to abort process<strong>in</strong>g for a<br />
request<br />
Spaghetti Code Warn<strong>in</strong>g: don't let your Filters<br />
reference one ano<strong>the</strong>r!<br />
Ashw<strong>in</strong> J Ma<strong>the</strong>w Spr<strong>in</strong>g 2008<br />
School of Information, UC Berkeley
Ashw<strong>in</strong> J Ma<strong>the</strong>w Spr<strong>in</strong>g 2008<br />
School of Information, UC Berkeley<br />
Visitor
Ashw<strong>in</strong> J Ma<strong>the</strong>w Spr<strong>in</strong>g 2008<br />
School of Information, UC Berkeley<br />
Double Dispatch
Ashw<strong>in</strong> J Ma<strong>the</strong>w Spr<strong>in</strong>g 2008<br />
School of Information, UC Berkeley<br />
Visit<strong>in</strong>g Nodes
Us<strong>in</strong>g Visitor<br />
●<br />
●<br />
●<br />
●<br />
Decouple operations to perform on a collection<br />
from <strong>the</strong> collection itself<br />
Def<strong>in</strong>e new operations without affect<strong>in</strong>g <strong>the</strong><br />
structure of <strong>the</strong> collection<br />
Polymorphic double dispatch based on type of<br />
object be<strong>in</strong>g visited<br />
The right code is executed based on types of<br />
both objects <strong>in</strong>volved <strong>in</strong> double dispatch<br />
Ashw<strong>in</strong> J Ma<strong>the</strong>w Spr<strong>in</strong>g 2008<br />
School of Information, UC Berkeley