Your SlideShare is downloading. ×
5 Classic Patterns In Everyday Code
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

5 Classic Patterns In Everyday Code

916
views

Published on

Patterns are an important tool to use as architects and developers. They provide a common vocabulary for us to design with, as well as a common approach to a common problem. Come learn about the five …

Patterns are an important tool to use as architects and developers. They provide a common vocabulary for us to design with, as well as a common approach to a common problem. Come learn about the five most useful patterns, and how to use them in your everyday code.


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
916
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
29
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. mike.wood@sds-consulting.com http://mvwood.com @mikewo on Twitter Strategic Data Systems Centerville, OH 5 Classic Patterns In Everyday Code Presented by: ArcTrax
  • 2. What are Patterns?
  • 3. Now for something COMPLETELY different!
  • 4. Design Principles
  • 5. S ingle Responsibility Principle O pen / Close Principle L iskov Substitution Principle I nterface Segregation Principle D ependency Inversion Principle
  • 6. Now back to your regularly scheduled presentation.
  • 7. Types of Patterns Creational Structural Behavioral
  • 8. Adapter Pattern
  • 9. Adapter Pattern Client IHuman .Speak() HumanWookieAdapter .Speak() Wookie .Growl()
  • 10. Adapter Pattern
  • 11. Decorator Pattern
  • 12. Decorator Pattern IceCreamIngredient .Cost public override decimal Cost() { return _internalIngredient.Cost() + .50M; } = $3.50 .Cost Vanilla Chocolate Bananas Ice Fudge .50 ¢ Cream .50 ¢
  • 13. Decorator Pattern
  • 14. Decorator Pattern What are some downsides with this pattern?
  • 15. Factory Patterns
  • 16. Simple Factory Pattern Laptop laptop; Public class LaptopFactory { switch (brand)BuildLaptop(string brand) { public Laptop { Laptop laptop; case “dell”: switch (brand) { case “dell”: laptop = new DellLaptop(); break; new DellLaptop(); return case “trashiba”: case return new ToshibaLaptop(); “trashiba”: laptop = new ToshibaLaptop(); }}} break; } LaptopFactory laptopFactory = new LaptopFactory(); Laptop laptop = laptopFactory.BuildLaptop(brand); laptop.BlueScreen(); Laptop.BlueScreen();
  • 17. Factory Method Pattern Shipyard .CreateShip() CorellianShipyard UsNavyShipyard
  • 18. Okay, so what what’s the difference between the simple factory and an instance of one of the derived factory classes? The both seem to do the same thing.
  • 19. Abstract Factory Pattern .CreateHero() .CreateVillian() Universe .CreateCity() DcUniverse MarvelUniverse Batman Wolverine Joker Magneto Gotham New York
  • 20. Factory Patterns
  • 21. Command Pattern
  • 22. Should it matter?
  • 23. Command Pattern Remote Command OffCommand .Execute() GarageDoorOpenCommand .Execute() GarageDoor .Open() .Close()
  • 24. Command Pattern
  • 25. Remember Design Patterns provide general, reusable solutions to a commonly occurring problem in software design
  • 26. Strategic Data Systems Centerville, OH mike.wood@sds-consulting.com http://mvwood.com @mikewo on Twitter ArcTrax
  • 27. mike.wood@sds-consulting.com Resources Presentation Materials http://shrinkster.com/15z6 Pattern Resource – Do Factory http://dofactory.com Patterns in Enterprise Software (Martin Fowler) http://shrinkster.com/15z8 Books: Design Patterns (Gang of Four book) Head First Design Patterns by Freeman & Freeman Refactoring to Patterns by Kerievsky More Resources can be found in the presentation materials.