Introduction to Java common design patterns and factory models

Source: Internet
Author: User

JavaWhat are the common design patterns? Describes the Factory mode.

Total at species, divided into three categories: creation, structural, behavioral

I only remember the usual ones. 6 , 7 species, respectively:

Created (Factory, factory method, abstract factory, Singleton)

Structural type (packaging, adaptors, combinations, proxies)

Behavior (Viewer, template, strategy)

then talk about your understanding of the patterns you are familiar with.   

Java in the at mode of design:

Factory (Factory mode), Builder (construction mode), Factory Method (factory method mode),

Prototype (original model mode), Singleton (singleton mode), facade (façade mode),

Adapter (Adapter mode), Bridge (bridge mode), Composite (synthetic mode),

Decorator (decorative mode), Flyweight (enjoy meta mode), Proxy (proxy mode),

Command (Command mode), Interpreter (interpreter mode), Visitor (visitor mode),

Iterator (iterative sub-mode), Mediator (mediator mode), Memento (Memo mode),

Observer (Viewer mode), State (state mode), Strategy (Policy mode),

Template Method (Template method mode), Chain ofresponsibleity (responsibility chain mode)

Factory mode: Factory mode is a frequently used pattern, and classes implemented according to the factory pattern can generate an instance of a class in a set of classes based on the data provided, usually this group of classes have a common abstract parent class and implement the same method, but these methods have different operations for different data. First, you need to define a base class in which subclasses implement methods in the base class in different ways. Then you need to define a factory class where the factory class can generate different subclass instances based on the criteria. When an instance of a subclass is obtained, the developer can call a method in the base class without having to consider which instance of the subclass is returned.

Introduction to Java common design patterns and factory models

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.