The relationship between Java design patterns, frameworks, architectures, and platforms

Source: Internet
Author: User
Tags java web

Design Patterns < Frameworks < Architectures < platforms, from a reuse perspective, the design pattern is code-level multiplexing, the framework is module-level reuse, the architecture is system-level multiplexing, and the platform is enterprise application-level reuse.

1. Design mode

Why do you say design mode first? Because design patterns are the most basic of these concepts, they are also relatively simple. So what is design mode? To be straightforward, the design pattern is to tell you how to organize the relationship between classes, objects, and interfaces for a particular problem, which is the experience of the predecessors. For example, I want to implement a globally unique configuration class in the code, then use the singleton mode. Design patterns are used in actual coding and design frameworks, while higher-level architectures and platforms don't pay much attention to it.

2. Framework

To do web development in contact with the most framework of the ORM Framework, ORM Framework is only the general term of all data relationship mapping framework, such as NHibernate, ActiveRecord, etc., the framework is to solve the specific problems exist, other such as template framework, caching framework, the framework can not be used directly , two development times are required.

3. Architecture

From a large level, such as business-to-consumer website system architecture, there may be a variety of solutions to solve various problems in the framework, focusing on technology integration, expansion, maintainability. In a different perspective, there are also architectural issues in the framework, such as the development of the NHibernate framework and the need to consider how to design it.

4. Platform

The concept of a platform is similar to a framework, but in combination with the architectural considerations, it is a higher level of "framework", which is exactly an application. It is for enterprise users, to solve the business needs of the products formed.

design mode (Patterns)

Mode: Detailed mode-click to open link

Design patterns are a set of reusable, most known, categorized purposes, code design experience Summary. Design patterns are used in order to reuse code, make code easier for others to understand, and ensure code reliability. There is no doubt that design patterns in others in the system are multi-win, design patterns so that code is truly engineering, design patterns are the cornerstone of software engineering, like a block of bricks and tiles in the building. The rational use of design patterns in the project can solve many problems perfectly, each of which has corresponding principles in the present, each of which describes a recurring problem around us, and the core solution of the problem, which is why it can be widely used.

Classification of design Patterns

In general, design patterns fall into three broad categories:

Create five types of models: Factory method mode, abstract Factory mode, singleton mode, builder mode, prototype mode.

Structure mode, a total of seven kinds: Adapter mode, adorner mode, proxy mode, appearance mode, bridging mode, combined mode, enjoy the meta-mode.

There are 11 types of behavioral Patterns: Strategy mode, template method mode, observer mode, iteration sub-mode, responsibility chain mode, Command mode, Memo mode, state mode, visitor mode, mediator mode, interpreter mode.

In fact, there are two types: concurrency mode and thread pool mode. Use a picture to describe it as a whole:

Six principles of design patterns

1. Opening and closing principle (Open Close Principle)

The open and closed principle is to say to the expansion opening, to modify the closure . When the program needs to expand, can not modify the original code, to achieve a hot plug effect. So a nutshell is: In order to make the program good extensibility, easy to maintain and upgrade. To achieve this, we need to use interfaces and abstract classes, which we will refer to later in the specific design.

2. The principle of substitution on the Richter scale (Liskov Substitution Principle)

One of the fundamental principles of object-oriented design of the Richter substitution principle (Liskov Substitution Principle LSP). The Richter substitution principle says that where any base class can appear, subclasses must be able to appear. LSP is the cornerstone of inheritance reuse, only if the derived class can replace the base class, the function of the Software unit is not affected, the base class can be really reused, and the derived class can also add new behavior on the basis of the base class. The principle of substitution on the Richter scale is a supplement to the principle of "open-closed". The key step in implementing the "open-close" principle is abstraction. The inheritance of the base class and subclass is the concrete implementation of abstraction, so the principle of the substitution of the Richter scale is the specification of the concrete steps to realize the abstraction. --from Baidu Encyclopedia

3. Dependence reversal principle (dependence inversion Principle)

This is the basis of the open and close principle, the specific content: TRUE interface programming, relying on abstraction and not dependent on the specific.

4. Interface Isolation principle (Interface segregation Principle)

This principle means that using multiple isolated interfaces is better than using a single interface. or a reduction of the coupling between the class meaning, from here we see, in fact, the design pattern is a software design ideas, from the large software architecture, in order to upgrade and maintenance convenience. So there are multiple occurrences: reducing dependency and reducing coupling.

5, Dimitri Law (least known principle) (Demeter Principle)

Why is it called the least known principle, that is to say: an entity should be as small as possible interaction with other entities, so that the system function module is relatively independent.

6. Synthetic multiplexing principles (Composite reuse Principle)

The principle is to use composition/aggregation as much as possible, rather than using inheritance.

(ii) Basic knowledge of the framework

(1): What is the framework?

Java framework: A three-frame explanation, its development process and the mastery of Java technology-click to open the link

Simple point: The framework is to complete a certain function of the semi-finished software, now the structure is, struts is responsible for the display layer, hibernate is responsible for the persistence layer, spring is responsible for the middle business layer, this structure is currently the most popular Java Web application architecture.

In its essence, the framework is a software, and is a semi-finished software. The so-called semi-finished, is still not fully realize the user needs of the function, the framework is only to achieve the user needs of the function part, but also need further processing, in order to become a user needs to meet the complete software. So frame-level software, its main customer is the developer, not the end user.

Some friends would like to think, since the framework is only a semi-finished, then why to learn and use the framework? The cost of learning is not small, that is because the framework can complete a certain function, that is, the "framework has been completed a certain function" in attracting developers, let everyone into the learning and use of the framework.

(2): What can the frame do?

Ability to complete certain functions to accelerate application development progress

Since the framework accomplishes a certain function, and is often a basic, difficult, general-purpose feature, it avoids the fact that we start from scratch at the time of application development, but continue to develop on top of what the framework already has, meaning that it will reuse the functionality of the framework to speed up the development of the application.

Give us a sophisticated program architecture

The framework defines the overall structure of the application, including the division of Classes and objects, the main responsibilities of each part, how classes and objects work together, and the control process, and so on. Most of the popular frameworks in the Java world now come from the Masters and are well designed. Development based on such a framework will generally follow the framework's already planned structure for development, thus making the structure of the application we develop relatively sophisticated.

(3): Understanding of the framework

Based on framework to develop, things or those things, just to see who did the problem

For the relationship between the application and the framework, you can use a diagram to describe briefly, 1, as follows:

Without a framework, all the features required by the customer are developed by the developer themselves, no problem, and the same can be done with the user's requirements, just a lot of work for the developer.

If there is a framework, the framework itself has completed a certain function, then the framework of the existing functions, the developer can not do, developers only need to complete the framework does not have functionality, and finally to complete all the functions required by the customer, but the developer's work is reduced.

That is to say, based on the framework to develop, the software to complete the function does not change, or customer requirements of all functions, that is, "things or things" means. But with the framework, the framework completes some of the functionality, and then the developer completes a subset of the functionality, and finally the framework and the developer complete the entire software function, which is the "who does" issue of these features.


(c) Structure

Software architecture is often referred to as architecture, which refers to a software framework that can be prefabricated and reconfigurable. Architecture is still in the development period, for its definition, academia has not formed a unified opinion, and different angles of view will also cause a different understanding of the software architecture, the following are some of the mainstream standard point of view.
ANSI/IEEE 610.12-1990 Software Engineering Standard glossary for the architecture definition is: "The architecture is based on the components, the relationship between components, the relationship between the component and the environment is the basic organizational structure of a system and know the design and evolution of the above content principle (principle)."
Mary Shaw and David Garlan that software architecture is a layer in the software design process that transcends algorithmic design and data structure design in computing. Architecture issues include organizational and global control structures for various aspects, communication protocols, synchronization, data storage, assigning specific functions to design elements, organization of design elements, scale and performance, and choice between design options. The basic ideas of the Garlan & Shaw model [1] are: Software architecture ={components (component), connectors (connector), constraints (constrain)}. A component can be a set of code, such as a program's module, or it can be a standalone program, such as a database server. A connector can be a procedure call, a pipe, a remote procedure call (RPC), and so on, to represent the interaction between artifacts. Constraints are generally the object of the rules when connecting, or indicate the form and condition of the component connection, for example, the upper component can require the service of the lower component, and vice versa; the two objects should not send the message in a recursive manner; the consistency constraint of the code copy migration, and the conditions under which the connection is invalid.
There are many other ideas about schema definition, such as the bass definition, Booch & rumbaugh &jacobson definition, Perry & Wolf model [7], Boehm model, and so on, although various definitions of key architectures differ in perspective, The research object is also slightly focused, but its core content is the structure of the software system, which is represented by the Garlan & Shaw model, emphasizing that the basic elements of the architecture are components, connectors and their constraints (or connection semantics), which are mostly from the structural point of view or even the software architecture, The definition of IEEE not only emphasizes the basic composition of the system, but also emphasizes the environment of the architecture, which is the interaction with the outside world.

(iv) Platform

Java is a programming language that can run on different operating systems (such as Windows,unix, etc.), and the Java platform is a system software that runs on a variety of terminals (such as PCs, servers, mobile devices, embedded devices). The Java program on the PC is developed with Javase, and the Java program on the server side is developed with Java EE, and the program of the mobile device is developed with Javame.

Mobile Platform:

J2ME (Java 2 Micro Edition) is an integral part of Java 2, which is associated with J2SE, EE, and the name. According to Sun's definition: J2ME is a highly optimized Java operating environment, mainly for consumer electronic devices, such as cellular phones and video telephony, digital set-top boxes, car navigation systems and so on. J2ME technology was formally launched at the 1999 JavaOne Developer Conference Conference, which ported the Java language's platform-agnostic features to small electronic devices, allowing applications to be shared between mobile wireless devices.

Desktop Application Platform:

J2SE commercial version, the standard version (JAVA2 standards Edition) is positioned on the client, primarily for programming of desktop applications. J2SE contains those classes that make up the core of the Java language.

Enterprise-Class Platform:

EE JAVA2 Platform Enterprise Edition (Java 2 platform,enterprise Edition), a set of technology architectures that are completely different from traditional application development, includes many components that simplify and standardize the development and deployment of application systems, thereby improving portability, Safety and re-use value. Java EE Core is a set of technical specifications and guidelines, including various types of components, service architecture and technical level, all have common standards and specifications, so that the different platforms following the Java EE architecture, there is good compatibility, to solve the past enterprise backend use of information products are incompatible with each other, The dilemma that makes it difficult for companies to communicate internally or externally.

(v) The total

1. The relationship between framework and architecture

Frameworks are not architectures (i.e. software architecture). The architecture determines the overall structure of the system, the level of division, and the collaboration between the different parts of the design considerations. Frameworks are more specific than schemas. More emphasis on technical suspicion. Once the framework is identified, the software architecture is also determined, and for the same software architecture, such as MVC in web development, can be achieved through a variety of frameworks.

2. The relationship between the framework and the design pattern

Design patterns and frameworks are two different research areas in software design. The design pattern is a solution to a design problem, a pattern can be applied to different frameworks and implemented by different languages, while the framework is an application architecture, a mixture of one or more design patterns and code, although they are different, but work together to make people's design can be reused, There are some characteristics of unity in ideology, so the thought of design pattern can be applied in frame design.

There are significant differences between frameworks and design patterns, mainly in the content provided by the two and in the fields of application.

1) from the field of application, the framework gives the entire application architecture, while the design pattern gives a solution to a single design problem, and the scheme can be applied in different applications or frameworks.

2) from the content, the design pattern is only a simple design, this design can be implemented in different languages without the way, while the framework is a mixture of design and code, programmers can extend the framework in a variety of ways, to form a complete and different applications.

3) based on the second article, it can be concluded that the design pattern is easier to transplant than the framework: once the framework is designed to form, though not yet a complete application, the development of the application based on it is obviously subject to the framework's implementation environment, and the design pattern is language-independent, so it can be applied in a wider range of heterogeneous environments.

In short, the framework is software, and the design pattern is the knowledge body of software, which improves the design level of the frame.

The relationship between Java design patterns, frameworks, architectures, and platforms

Related Article

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.