0.1 what is the design model and 0.1 the design model

Source: Internet
Author: User

0.1 what is the design model and 0.1 the design model

[GoF · Chapter 2 Conclusion] IntroducesThe Birth and Development History of design patterns: "Architect Christopher Alexander first studied the patterns of buildings and communities and developed a" Pattern Language "to generate them. His work inspired us again and again 』

For most programmers who are not familiar with the construction industry or "Model language,Mode/patternIs relatively tall. In fact, my personal favorite saying is:Techniques! For example, the solutions or methods of Chinese chess.

Chinese chess metaphor

For example:


Question: In the current situation, how can the red party defeat the black party.

People who can play Chinese chess will surely find a way: they can lock the game by placing a gun behind the hacker. This commonly-used vulnerability killing method has a name called "haidilao Yue ".


Pattern)Is a solution to a problem in a specific environment/condition.

Specific environment: the prerequisite for haidilao is that the red car occupies the Middle Road. In design patterns, a specific environment is part of the problem.

1. Name: "haidilao Yue" represents a Chinese chess board Board (problem), solutions under this board, various changes and solutions. The name of the model, whether it's a player or a programmer, is very helpful for them to discuss issues. These names are part of their professionalism and professional vocabulary. Documentation is an important part of software development. For example, a framework such as Spring document is an important document for programmers who learn to use this framework. Using the pattern name in the document allows people who know the design pattern to understand the system more quickly.

When learning Java I/O streams, it will be easy if you know the decoration mode and adapter mode.

2. Problem Description

In general, [GoF] "records" or summarizes 23 design patterns. Therefore, it writes: "problem ),Describes when to use the mode....... Sometimes, the problem part includes a series of prerequisites that must be met in the usage mode 』. In [GoF · 1. 3. Description of the Design Pattern]: The book describes each pattern based on a specific template. The template includes: pattern name and classification, intent, motivation, applicability, structure, participants, collaboration, effect, implementation, code examples, known applications and related patterns. Therefore, the problem is described"Intention" and "motivation". This is a summary after induction.

Assume that our basic learning method isDeductionIn other words, hopeStart from the problem and find out the corresponding techniques or modelsThen, our problem description may start from a point, and the resulting mode can be applied to more aspects. You know the principles of haidilao Yue. Of course, it's easy to say how the Red-square car soldiers beat the black-square bicycle.

3. Solution

The solution for haidilao Yue is to play games. You can do it yourself if you don't know how to play games.

The design pattern is a problem-solving template in the design, which is usually presented as a class diagram or structure. To make it easier for readers to understand, class diagrams are often added in books or articles. We simply use simple class diagrams formed by the source code of BlueJ. The source code will be placed in the designPattern folder for readers to download.

4. Evaluation

The evaluation of the chess game method is straightforward, successful or failed. The evaluation of design patterns involves many factors. The basic evaluation is whether the model solves specific problems, so that the design is more in line with the design principles, the software is more flexible and maintainability. However, "software effects mostly focus on measuring time and space", and such evaluations are more targeted at algorithms.


Pattern)Is a solution to a problem in a specific environment/condition.

Bytes †Design ModeIs a solution to a design problem in a specific environment or condition. It contains four elements (although we have made some modifications to all four elements ).

Other definitions: The [GoF] Design Pattern describes the classes and communication objects used to solve general design problems in specific scenarios.




What are the differences between Java Enterprise design patterns and design patterns?

The java Enterprise Design Pattern focuses on the big framework. For example, the comprehensive application of struts1 struts2 spring is Framework-oriented. The design pattern refers to a small aspect, such as 23 design patterns!
Reprinted, please keep the source and respect others' work.
Introduction:

The definition of the pattern seems to be exactly the same, but they all seem to be slightly different. The differences caused by different concerns make things a little complicated.

Brief history:

What is the design pattern? Any book that explains software design patterns will first ask this question. Most of them will give a definition of the origins of the legendary software design patterns:

"Each mode is a rule consisting of three parts, which represents the relationship between a specific environment, a problem, and a solution.

...

Simply put, a pattern is a physical object that appears in the world and a rule that tells you how to create a physical object and when to create it. It is both a process and a physical object. It is both a description of the current physical object and a description of the process of creating the physical object ." -- The Eternal path of building

"Abstract solutions for repeated design problems"-architectural model language

Subsequently, these concepts are constantly localized in books on different software design patterns:

In Design Pattern of Gof (Gang of four), the Pattern is defined as three values: Pattern indicates the relationship between a specific situation, problem, and solution.

In J2EE core Patterns, a pattern is used to describe the communication problems and their solutions.

The conclusion of model-Oriented Software Architecture: A Software Architecture Model describes a special reproduction design problem in a specific design context, and provided a fully verified general scheme for her solution. The solution scheme is specified by describing its components, their responsibilities and relationships, and their collaboration methods.

Of course, there are also related discussions in some other books: The model is an "example"; it is to consider a pair of problems at the same time, the "expert behavior" of the solution, and so on ......

Opinion:

These ideas and concepts seem to be exactly the same, but they all seem to be slightly different. These differences caused by different concerns make things a little complicated. When I was browsing these books, I was wondering if I should summarize my own understanding? OK. Let me do it myself.

Definition:

Broadly speaking, a model is an environment where a typical problem that has been repeatedly encountered is illustrated with a solution that has been demonstrated, and an abstract description of the overall relationship between the three.

To facilitate memory, the sequence can be expressed:

Environment: scenarios where problems occur and solutions are available.

Problem: A recurring typical problem that can be covered by a solution in the environment.

Solution: strategies and methods that have been proven to be able to solve a typical problem in the context.

Relationship: closely related to the three points mentioned above.

Mode: The overall abstract description of the above four points.

The software design model should be clear at a glance:

The Software Design Model refers to the solution to software design problems in the software field ).

To facilitate memory, the sequence can be expressed:

Environment: Software Design

Problems: Software Design Problems

Software design pattern: There are two advanced pattern (generalized pattern ).

Now the definition of Haha is clear.

Features:

In the previous definition, we can see the features of many models, such as the overall abstraction, the repeatability of the problem, the justification of the solution, and the closeness of the relationship. In fact, the pattern has some hidden features.

Adequacy: the model is actually a fully tested experience and reusable knowledge. It and experience-based theory, evidence-based theory, is the product of the most basic cognitive method induction of mankind.

Dynamic and Static: The pattern describes both an abstract object and an abstract process.

The same as the definition, the software design pattern also inherits these features .... Remaining full text>

What is DAO design mode?

DAO design mode learning Sprint (8 months) read 88 comments 0 font size: large and small DAO design mode DAO (Data Access Object) mode is actually a combination of two modes, data Accessor mode and Active Domain Object mode. Data Accessor mode separates Data access from business logic, while Active Domain Object mode, the Data Accessor mode separates Data access from business logic, while the Active Domain Object mode encapsulates business Data in an object-oriented manner. Generally, we use these two modes in combination. Therefore, taking these factors into account, we will discuss them here as the same topic. Shows the implementation layers of the DAO mode.

The DAO mode provides the data abstraction layer interface to the business layer to achieve the following goals:

1. Separation of data storage Logic
Abstract The data access logic to provide abstract data access interfaces for upper-level organizations. The business layer does not need to care about the specific select, insert, and update operations. In this way, the hybrid JDBC call statements in the Business Code are avoided to make the business implementation clearer. On the other hand, as data access is separated by several verbal data access methods, it is also possible for developers to divide their professional skills. Some developers proficient in database operation technology can optimize database access based on interfaces, while those proficient in business can focus on business logic coding without the tedious details of data Zeng de.

2. Isolation of underlying data access
The DAO mode separates the data access plan into abstract and previous implementations, thus separating the detailed implementation details of data usage and data access. This means that the business layer has nothing to do with the underlying details of data access. That is to say, we can modify the specific data access mechanism by switching the underlying implementation while the upper-level organizations remain unchanged, A common example is to deploy our system on different database platforms by simply replacing data access.

3. Separation of resource management and scheduling
In database operations, resource management and scheduling are a very important topic. The performance bottleneck of most systems is often not concentrated on the business logic processing itself. During the scheduling of various resources involved in the system, the maximum performance black hole often exists. As the most important system resource in the business system, the database naturally becomes the focus of attention. The DAO mode separates the data access logic from the business logic, making it possible to implement unified resource scheduling at the data access layer. The database connection pool and various caching mechanisms (Statement Cache, data Cache and so on, the use of Cache is a key to the implementation of high-performance systems), often can keep the upper-level system unchanged, greatly improve the system performance.

4. Data abstraction
In code directly called Based on JDBC, the data that the programmer faces is often the original RecordSet dataset. It is true that such a dataset can provide sufficient information, but for the business logic development process, such trivial and meaningless field data is boring.
By encapsulating the underlying data, DAO provides an object-oriented interface for the business, so that the business logic developer can encode the entities in the business. By introducing the DAO model, the business logic is clearer and descriptive, which will bring great convenience for future maintenance. Imagine that the Customer was used in the business. the getName method obtains the customer name. which method is easier to visualize and simplify the business logic than directly accessing the database table through SQL statements and obtaining a complex field from the ResultSet?

There is no value to talk about some theories in an empty way. What we need to see is how our code changes after the application design pattern, in this way, we can feel the advantages and disadvantages of the design. Let's take a look at the Code:

[Code] Public BigDecimal calcAmount (String cust ...... full text>

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.