design_patterns_I - CSE 332: Design Patterns Introduction...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSE 332: Design Patterns Introduction to Design Patterns Youve seen design patterns several times this semester The Iterator pattern has been discussed in some detail (STL lectures) Weve also seen the Factory Method pattern (but havent named it yet) This lecture will focus on design patterns in detail What they are and how they are structured (in detail) Introduction to some of important design patterns (from Gamma et al.) Well work through a design exercise step by step Each time we come to a design problem well introduce a design pattern Well see how the pattern resolves the problem Next lecture well talk about how to combine sets of patterns Create design pattern languages that also can be reused Todays patterns form a pattern language, though we wont consider them in that way until weve reached the end of the design exercise CSE 332: Design Patterns Whats a Design Pattern? A design pattern has a name So when someone says Adapter you know what they mean So you can communicate design ideas as a vocabulary A design pattern describes the core of a solution to a recurring design problem So you dont have to reinvent known design techniques So you can benefit from others (and your) prior experience A design pattern is capable of generating many distinct design decisions in different circumstances So you can apply the pattern repeatedly as appropriate So you can work through different design problems using it CSE 332: Design Patterns Pattern-Oriented Design Well start by outlining a simple design exercise (Part I) Idea: maintain a portfolio of stocks and bonds Design goals Traverse the portfolio and print out each element Print out the portfolio in different orders Provide a common interface to a single portfolio instance Calculate current and projected values of the portfolio Well see how key patterns drive the design (Part II) Iterator: access elements sequentially no matter how stored Factory method: create a related type polymorphically Singleton: provides access to a single instance Strategy: makes behaviors pluggable via common interfaces Adapter: converts an interface you have into one you want Visitor: allows interaction with heterogeneous collections Well talk about how weve evolved a pattern language (Part III) Can be reused different design settings where the same issues arise CSE 332: Design Patterns Part I: Design Exercise Outline Idea: keep track of a portfolio of stocks and bonds Abstractly, both stocks and bonds are securities Each has a name, a number of shares, a current value, and a projected value Stocks and bonds are distinct abstractions, however Stocks can have a dividend thats paid out periodically Bonds can earn interest thats also paid out periodically Design goals Traverse the portfolio and print out each element...
View Full Document

Page1 / 19

design_patterns_I - CSE 332: Design Patterns Introduction...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online