Design Pattern -- create pattern -- abstract factory pattern -- java

Source: Internet
Author: User

Intent • Provide an interface for creating families of related ordependent objects without specifying their concrete classes. • provides an interface to create object families with relationships or dependencies without using specific classes. UMLApplicability • a system shoshould be independent of how its products arecreated, composed, and represented. • a system must be independent of product creation, combination, and representation. • A system shoshould be configured with one of multiplefamilies of products. • a system must be configured by one of multiple product families. • A family of related product objects is designed to beused together, and this constraint youneed to enforce. • Product families are used for joint use and some restrictions are enforced. • You want to provide a class library of products, and youwant to reveal just their interfaces, not their implementations. • you need to provide some product class libraries and you only use their interfaces. Instead of implementing them. Consequences • It isolates concrete classes. • separates specific classes. • It makes exchanging product families easy. • make product families easier to change. • It promotes consistency among products. • Benefits for product family consistency • Supporting new kinds of products is difficult. • It is difficult to support new products. Product level structure multiple product level structure the specific UML TankGameUML of the Product Family • Elements in TankGame are divided into vector and image versions. Therefore, there are two product families for product roles. Two factories. Factory method UML and abstract factory comparison factory method focuses on FactoryMethod () in Creator Abstract Factory focuses on AbstractFactory1. When the product level structure is added, the open and closed principles are not met. 2. When a product family is added and a product family is added, the open and closed principle is met.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.