Содержание
- 2. Christopher Alexander says, "Each pattern describes a problem which occurs over and over again in our
- 3. Must have… and must read…
- 4. Desing patterns classification Creational patterns concern the process of object creation. Structural patterns deal with the
- 5. Abstract Factory Creational pattern Provide an interface for creating families of related or dependent objects without
- 6. AbstractFactory - declares an interface for operations that create abstract products Abstract Factory: participants ConcreteFactory -
- 7. Abstract Factory: UML class diagram
- 8. CarFactory. Step 1
- 9. Car Factory. Step 2
- 10. Car Factory. Step 3
- 11. Car Factory. Step 4
- 12. Abstract Factory: example. Abstract Factory - CarFactory abstract class CarFactory { public abstract AbstractCar CreateCar(); public
- 13. Concrete Factory - BMWFactory class BMWFactory : CarFactory { public override AbstractCar CreateCar() { return new
- 14. class AudiFactory : CarFactory { public override AbstractCar CreateCar() { return new AudiCar(); } public override
- 15. abstract class AbstractCar { public abstract void MaxSpeed(AbstractEngine engine); } Abstract Factory->Abstract Product abstract class AbstractEngine
- 16. Class implementation - BMWCar class BMWCar : AbstractCar { public override void MaxSpeed(AbstractEngine engine) { Console.WriteLine(«Max
- 17. class AudiCar : AbstractCar { public override void MaxSpeed(AbstractEngine engine) { Console.WriteLine(«Макcимальная скорость: « + engine.max_speed.ToString());
- 18. class Client { private AbstractCar abstractCar; private AbstractEngine abstractEngine; public Client(CarFactory car_factory) { abstractCar = car_factory.CreateCar();
- 19. public static void Main() { // Abstract Factory № 1 CarFactory bmw_car = new BMWFactory ();
- 20. Builder Pattern Creational pattern Separate the construction of a complex object from its representation so that
- 21. Builder - specifies an abstract interface for creating parts of a Product object Builder: participants ConcreteBuilder
- 22. Builder: UML class diagram
- 23. Builder
- 24. Builder. UML
- 25. Builder: Example HappyMeal, BigHappyMeal class HappyMeal { // contains information about parts of HappyMeal ArrayList parts
- 26. Builder. Example Declare a builder - an abstract interface for creating an object in parts abstract
- 27. Builder Declare a concrete builder BigHappyMeal { class BigHappyMealBuilder : HappyMealBuilder { private HappyMeal happy_meal =
- 28. Builder Declare a concrete builder HappyMeal class SmallHappyMealBuilder : HappyMealBuilder { private HappyMeal happy_meal = new
- 29. Builder Class Director – will construcr the object class Director { // Constructing the object in
- 31. Скачать презентацию