Common design Patterns in a project

Source: Internet
Author: User

This article for Bo Master original, allow reprint, but please declare the original address: http://www.coselding.cn/blog/4/4-117.html

  1. Business Rep Mode: (query selection method for different implementations of the same interface)

    Steps:

    • Business interface;
    • Business interface implementation, multiple;
    • The query class implemented by the business interface implements the corresponding interface implementation class according to the keyword;
    • Business representative: Maintain a business query class and a business interface reference, keyword settings, execution method in accordance with the keyword to obtain a business implementation class reference, and use the business to perform the corresponding functions;
    • Business representatives can achieve the appropriate business processing through the business representative, and need to implement the set of keywords.
  2. Combining Entity Patterns: (attribute integrity in complex entities read-write, maintain data consistency)

    Steps:

    • Create dependent objects;
    • Create coarse-grained objects, maintain the references of multiple dependent objects internally, and complete the corresponding SetData and GetData methods to read and write the data in the dependent objects as a whole;
    • Create composite entity objects, control references to multiple coarse-grained objects, and read and write all data in the same way as coarse-grained objects;
    • The caller reads and writes the data in the composite entity object as a whole.
  3. < Span style= "margin:0px; padding:0px; border:0px; outline:0px; Vertical-align:baseline; font-family: Microsoft ya black; Background:transparent "> Data Access Object mode: (is DAO mode)

    step:

    implement additions and deletions to an entity, where the query can have all queries and a single query

  4. Front-end controller mode:

    Used for authentication/authorization/logging, and processing requests, returned to the user corresponding interface, is used to process all requests of the total controller.

    Steps:

      • Scheduler: Select the corresponding interface output through keywords;
      • Front Controller: Authentication, request recording, authorization, and select the corresponding interface output through the scheduler
  5. Block Filter Mode:

    Steps:

    • Filter interface and filter method;
    • Filter interface Implementation;
    • Filter Chain: Maintain filter set, delete method, Execute method, execute all filters before executing target code;
    • Filter Management class: Control the implementation of the filter chain;
    • Requestor class: Invokes the filter manager to execute the request.
  6. Service Locator Mode:

    Querying a service with Jndi is expensive, caches the service after the first query, and gets the service directly from the cache the next time it improves performance.

    Steps:

      • Cache class Caches: maintains a collection of services, queries the service through the keyword, does not query the return NULL, and the service is added (to ensure the uniqueness of the service in the collection);
      • Service Locator class: maintain a cache class reference, through the keyword query service, first check the cache, if the cache is not again through the Jndi Query service, and the service into the cache.
  7. Transfer Object mode:

    Implements the transport functionality of the entity's server client, using serialization and deserialization methods.

    • Encapsulates an object entity, and the properties are serializable;
    • Reads data from the database to populate the entity;
    • Serialization of entities to the client;
    • The client deserializes the original entity object and completes the object network transmission function.

This article for Bo Master original, allow reprint, but please declare the original address: http://www.coselding.cn/blog/4/4-117.html

Common design Patterns in a project

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.