Summary of common Java Modes

Source: Internet
Author: User
Document directory
  • Interface Mode
  • Responsibility Model
  • Constructor Mode
  • Operation Mode
  • Extended Mode

Excerpted from: Design Patterns Java Manual

Interface Mode

Adapter ModeThe purpose is to use the services provided by existing classes to modify their interfaces to meet user expectations.

Appearance ModeIt is designed to provide an interface for subsystems to make them easier to use.

Combination ModeThe aim is to allow users to process a single object and a combination of objects with a unified interface.

Bridging ModeThe purpose is to separate abstract (class dependent on abstract operations) from the implementation of abstract operations, so that abstraction and implementation can be changed independently.

Responsibility Model

Standalone ModeIt is designed to ensure that a class has only one instance and provide a global access point for it.

Observer ModeThe purpose is to define a one-to-many dependency between multiple objects so that when the state of an object changes, all other objects dependent on this object can be notified and automatically updated.

Intermediary ModeIt is designed to define an object to encapsulate the interaction mode between a group of objects, so as to avoid explicit reference between objects and modify the interaction between these objects separately.

Proxy ModeIt is designed to provide a proxy for an object to control access to this object.

Responsibility Chain ModelThe purpose is to forward a method call request along the responsibility chain to the next object, so that each object has a chance to decide whether to process the request, this reduces the coupling between the request sender and the receiver.

Meta ModeIt aims to provide effective support for a large number of fine-grained objects through sharing.

Constructor Mode

Generator ModeThe purpose is to move the code logic of the constructed object instance to the outside of the class.

Factory method modeIt is designed to define an interface for creating objects and control which class to instantiate.

Abstract Factory ModelIt is designed to create a series of interrelated or interdependent objects.

PrototypeIt is designed to copy an existing object to generate a new object.

Memorandum ModeIt is designed to provide state storage and State recovery for objects.

Purpose

Application Mode

Collect the construction-related information of the object step by step before constructing the object.

Generator Mode

Deferred determination of classes to be instantiated

Factory method mode

Construct a series of objects with a certain public feature

Abstract Factory Model

Construct an object based on the given example

Prototype

Creates an object from the object's sleep version. This sleep version contains the internal status of the object.

Memorandum Mode

Operation Mode

Template Method ModeIt is designed to implement an algorithm in a method and delay the definition of some steps in the algorithm, so that other classes can redefine these steps.

Status ModeIt is designed to distribute state-related processing logic to various classes that represent object states.

Rule ModeIt is designed to encapsulate optional policies or schemes in different classes and implement a common operation in these classes.

Command modeThe purpose is to encapsulate a request as an object and take the request object as a parameter. You can provide different request objects, such as the queue request, time request, or diary request, or request the accompanying operation, such as the Undo () operation.

Interpreter ModeIt is designed to enable users to generate executable objects based on custom combination rules.

Extended Mode

Decorator ModeThe aim is to enable developers to dynamically organize the behavior of objects.

Iteration ModeIt is designed to provide developers with a method for sequential access to set elements.

Visitor ModeIt is designed to enable code users to expand the behavior of the existing class hierarchy without modifying the existing class hierarchy.

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.