mike.wood@sds-consulting.com
http://mvwood.com
@mikewo on Twitter                  Strategic Data Systems
                ...
What are Patterns?
Now for something
COMPLETELY different!
Design Principles
S ingle Responsibility Principle
O pen / Close Principle
L iskov Substitution Principle
I nterface Segregation Principle
D...
Now back to your regularly
 scheduled presentation.
Types of Patterns
 Creational


                Structural


 Behavioral
Adapter Pattern
Adapter Pattern
Client      IHuman
                  .Speak()

 HumanWookieAdapter
               .Speak()

              ...
Adapter Pattern
Decorator Pattern
Decorator Pattern
 IceCreamIngredient
    .Cost
                  public override decimal Cost()
                  {
     ...
Decorator Pattern
Decorator Pattern
What are some downsides with this pattern?
Factory Patterns
Simple Factory Pattern
Laptop laptop;
  Public class LaptopFactory {
switch (brand)BuildLaptop(string brand) {
   public L...
Factory Method Pattern
            Shipyard
                         .CreateShip()


                       CorellianShipy...
Okay, so what what’s the
  difference between the simple
factory and an instance of one of
 the derived factory classes? T...
Abstract Factory Pattern
                               .CreateHero()
                               .CreateVillian()
    ...
Factory Patterns
Command Pattern
Should it matter?
Command Pattern
 Remote                     Command
  OffCommand                   .Execute()

                 GarageDoor...
Command Pattern
Remember

 Design Patterns provide
general, reusable solutions to a
commonly occurring problem in
software design
Strategic Data Systems
   Centerville, OH




 mike.wood@sds-consulting.com

                 http://mvwood.com

         ...
mike.wood@sds-consulting.com
Resources
Presentation Materials
      http://shrinkster.com/15z6

Pattern Resource – Do Fact...
5 Classic Patterns In Everyday Code
5 Classic Patterns In Everyday Code
5 Classic Patterns In Everyday Code
5 Classic Patterns In Everyday Code
5 Classic Patterns In Everyday Code
5 Classic Patterns In Everyday Code
5 Classic Patterns In Everyday Code
5 Classic Patterns In Everyday Code
Upcoming SlideShare
Loading in...5
×

5 Classic Patterns In Everyday Code

974

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 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
974
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
29
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

5 Classic Patterns In Everyday Code

  1. 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. 2. What are Patterns?
  3. 3. Now for something COMPLETELY different!
  4. 4. Design Principles
  5. 5. S ingle Responsibility Principle O pen / Close Principle L iskov Substitution Principle I nterface Segregation Principle D ependency Inversion Principle
  6. 6. Now back to your regularly scheduled presentation.
  7. 7. Types of Patterns Creational Structural Behavioral
  8. 8. Adapter Pattern
  9. 9. Adapter Pattern Client IHuman .Speak() HumanWookieAdapter .Speak() Wookie .Growl()
  10. 10. Adapter Pattern
  11. 11. Decorator Pattern
  12. 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. 13. Decorator Pattern
  14. 14. Decorator Pattern What are some downsides with this pattern?
  15. 15. Factory Patterns
  16. 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. 17. Factory Method Pattern Shipyard .CreateShip() CorellianShipyard UsNavyShipyard
  18. 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. 19. Abstract Factory Pattern .CreateHero() .CreateVillian() Universe .CreateCity() DcUniverse MarvelUniverse Batman Wolverine Joker Magneto Gotham New York
  20. 20. Factory Patterns
  21. 21. Command Pattern
  22. 22. Should it matter?
  23. 23. Command Pattern Remote Command OffCommand .Execute() GarageDoorOpenCommand .Execute() GarageDoor .Open() .Close()
  24. 24. Command Pattern
  25. 25. Remember Design Patterns provide general, reusable solutions to a commonly occurring problem in software design
  26. 26. Strategic Data Systems Centerville, OH mike.wood@sds-consulting.com http://mvwood.com @mikewo on Twitter ArcTrax
  27. 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.
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×