tailieunhanh - head first design patterns phần 4

Có chức năng được sử dụng để khởi tạo xử lý chuột? A. install_mouse 7. Những giá trị hoặc các chức năng được sử dụng để đọc các vị trí con chuột? A. mouse_x và mouse_y 8. Những chức năng được sử dụng để đọc x chuột và các mickeys y cho chuyển động tương đối? D. get_mouse_mickeys 9. | the factory pattern That s a fairly complicated class diagram let s look at it all in terms of our PizzaStore The clients of the Abstract Factory are -the two _ instances of our PixzaStore c KyPiixaStore and V Chica oStylePizzaStore- NYPizzaStore OBStePinaO The abstract PizxalnyedientFactory a the interface that defines how to make a family of related products - everything we need to make a pizza- lntertace aestiũoughị ơmíoSsicạ ị ct stoCteeseị acữtù ỹỌỊ sf cre oPewerorrf cmatũữamủ nferface Dough r p ThickCrustDough ThlnCrustDough int rfacc Sauce Ĩ PlumTomatoSauce MarinaraSauco interfaco Choose -----------F NYPizzalngredientFactory ChlcagoPizzalngredientFactory nil 0-eữtũDx jh ceate xxeO ơeatcChocsôl . ơe3toPe pcrcnO creaỉoClamQ The job of the Concrete factories is to make p izz-3 ingredients Bach factory knows how to create the ri ht objects for their region Mozzarella Cheese interíace Clams RegglsnoCheese FrozenClams FreshClarrre Baeh factory produces a different implementation for the family of products you are here 157 interview with factory patterns I noticed that each method in the Abstract Factory actually looks like a Factory r Method createDough createSauceQ etc. . Each method is declared abstract and the subclasses override it to create some object. Isn t that Factory Method Is that a Factory Method lurking inside the Abstract Factory Good catch Yes often the methods of an Abstract Factor arc implemented as factory methods. It makes sense right The job of an Abstract Factory is to define an interface for creating a set of products. Each method in that interface is responsible for creating a concrete product and wc implement a subclass of the Abstract Factory to supply those implementations. So factory methods arc a natural way to implement your product methods in your abstract factories. Patterns Exposed This week s interview Factory Method and Abstract Factory on each other HeadFirst Wow an interview with two patterns at once This is a