Relationship between frameworks and Design Patterns

Source: Internet
Author: User
Tags to domain
A framework is a semi-finished product of an application. The framework provides a public structure that can be shared between applications. Developers integrate frameworks into their own applications and expand them to meet their specific needs. The difference between a framework and a toolkit is that the framework provides a consistent structure, not just a set of tool classes.
The framework is actually a group of parts for you to choose to complete your own system. Simply put, you can use a stage set up by others to perform performances. In addition, the framework is generally mature and constantly upgraded software.
It can be said that a framework is a reusable design component, which defines the application architecture and clarifies the dependency, responsibility allocation and control processes between the entire design and collaboration components, it is represented as a group of abstract classes and methods for collaboration between their instances. It provides context relationships for Component reuse. Therefore, the large-scale reuse of Component Libraries also requires a framework.
The Framework Method in the component field draws on the development achievements of hardware technology to a great extent. It is the product of the development combination of component technology, software architecture research and application software development. In many cases, the Framework usually appears as a component library, but the component library is only an important part of the framework. The key of the framework is the interaction mode and control flow mode between objects in the framework.
The framework is more customizable than the component. To some extent, it may be better to regard components and frameworks as two different technologies that work together. The framework provides a reusable environment for components, and provides a standard method for component error handling, data exchange, and activation operations.
The concept of the application framework is also very simple. It is not a small program that contains component applications, but an underlying service that implements a general and complete function (excluding the special application) in an application field. Programmers who use this framework can start specific system development based on the implementation of a common function. The framework provides a set of classes for all applications to expect the default behavior. A specific application supports the application-specific behavior by overwriting the subclass (which belongs to the default behavior of the Framework) or assembling the object.
The Application Framework emphasizes software design reusability and system scalability to shorten the development cycle of large-scale application software systems and improve the development quality. Compared with the traditional class library-Based Object-Oriented reuse technology, the application framework focuses more on software reuse in specialized fields. The application framework is subject to domain relevance. components are composite based on the framework to generate a workable system. The more powerful the framework is, the more complete the domain knowledge it contains.
Relationship between frameworks and Design Patterns
The concepts of frameworks and design patterns are always confusing, but there are still differences between them. The component is usually code reuse, while the design pattern is design reuse. The framework is between the two. Some code is reused, some design is reused, and sometimes analysis is reusable. There are three levels of reuse in software production: Internal reuse, that is, abstract blocks that can be commonly used in the same application; code reuse, which combines common modules into libraries or tool sets, it can be used in multiple applications and fields. the reuse of application frameworks provides general or ready-made infrastructure for specialized fields to achieve the highest level of reusability.
Although the framework is similar to the design model, it is fundamentally different. The design pattern is a description of the problem that occurs repeatedly in a certain environment and the solution to the problem. It is more abstract than the framework. The framework can be expressed in code and can be directly executed or reused, for patterns, only instances can be represented by code. design patterns are smaller elements than frameworks. A framework usually contains one or more design patterns, the framework always targets a specific application field, but the same pattern can be applied to various applications. It can be said that the framework is software, while the design mode is software knowledge.
Why use the framework?
As software systems have become very complex today, especially the knowledge, content, and problems of server-side software and design. Using someone else's mature framework in some ways is equivalent to letting someone else do some basic work for you. You only need to concentrate on completing the business logic design of the system. In addition, the framework is generally mature and robust. It can handle many details of the system, such as transaction processing, security, and data flow control. There are also frameworks that are generally used by many people, so the structure is very good, so the scalability is also good, and it is constantly upgraded, you can directly enjoy the benefits of other people upgrading code.
The framework is generally located at the intermediate layer between the low-level application platform (such as J2EE) and the high-level business logic.
The criteria for measuring the level of application system design and development are decoupling. Can all functions of your application system be completely detached? Whether or not they are independent, and only in this way can the maintainability and scalability of software design goals be reflected.
To achieve this purpose, various Framework concepts were created. The J2EE framework standard divides a system into the main parts of Web and EJB. Of course, we sometimes do not distinguish this specific technology, instead, it is abstracted from the design to the presentation layer, service layer, and persistent layer. These three layers separated J2EE from each other to achieve decoupling.
Therefore, in actual programming, We need to align our functions to these three levels to make the general direction clear and distinct, however, it is not easy to do this without technical constraints. Therefore, we must use the specific J2EE technology. At this time, you can use the EJB specification to implement the service layer and persistence layer, web technology implementation presentation layer;
Why can EJB separate the service layer from the JSP/servlet, because it has mandatory constraints on the JavaBeans encoding, and now there is a weak constraint on the JavaBeans, implemented in the IOC mode (of course, this method is also used in EJB 3.0). Prior to the birth of the IOC mode, the factory mode was generally used to constrain the javans and form a service layer, this is also one of the design principles of open source forums such as jive.
Therefore, the service layer is separated from the presentation layer. Currently, there are two optional architecture options: managing the common ans (pojo) framework (such as spring and jdonframework) and managing the EJB framework, because EJB is not just a framework or a standard, but a standard can be extended and developed, the two differences may be vague in the future and incorporated into the same standard. However, I personally think: standards are designed to serve a specific purpose, and they always have to sacrifice some in exchange for others. Therefore, these two architectures will coexist for a long time.
These two kinds of architecture differences have also emerged as a new term: a fully pojo system is also called a lightweight System (lightweight). In fact, this term is not strictly defined by itself, what's more, it's an attractive sign. Is light weight easy to learn and use? According to this definition, simple spring and other systems are not easy to learn. Can systems after EJB 3.0 (still called EJB) be called Lightweight?
Previously, I talked about the service layer framework. The service layer framework can be used to separate ans from JSP/servlet, while the presentation layer framework can be used to completely separate the remaining JavaBeans in JSP, these JavaBeans are mainly responsible for display. Generally, they are implemented through taglib. Different frameworks have different tag libraries. Struts is a widely used presentation layer framework.
In this way, the separation between the presentation layer and the service layer is achieved through two frameworks, and the rest is the persistence layer framework, the purpose of separating database storage from the service layer through the persistence layer framework is that the persistence layer framework has two directions: Directly Writing JDBC and other SQL statements (such as ibatis ); hibernate and JDO technologies implemented using the O/R Mapping technology; of course, there is also the Entity Bean Technology in EJB.
The persistence layer framework is currently available in a variety of ways, with its own advantages and disadvantages. So, just like the presentation layer framework, no framework is currently specified as a standard framework. Of course, the presentation layer framework now comes up with another JSF, which represents the concept of page components as a new development direction, but complicated implementations are somewhat confusing.
Sun has played a major role in all of these J2EE technologies, but in general, sun's theory is invincible; sun products are used to hit the wall. For Beginners, especially those who attempt to pass or have already passed the sun certification, they can quickly get rid of the Sun Shadow and get away immediately, use open-source products to implement your own application systems.
Finally, if your J2EE application system is implemented using the framework of the presentation layer, service layer, and persistence layer mentioned above, you can also develop a high-quality application system without having to have a deep understanding of the design model.
It should also be noted that the development of a high-quality J2EE system requires correct understanding of business requirements, so Domain Modeling provides a more practical and feasible way to correctly understand business requirements, the detailed knowledge can be understood from the UML perspective.
Of course, if you want to design your own industrial framework, start with the design mode, because the design mode provides you with a reference implementation method to implement decoupling between JavaBeans or classes, when you learn how to decouple the system's basic unit JavaBean or class, you may be able to master the decoupling between system modules, and then you can refine the industry framework, this is another development direction.
The biggest benefit of the Framework is reuse. The most reusable method obtained by object-oriented systems is the framework. A large application system may be composed of multi-layer collaborative frameworks.
Since the framework can reuse code, it is very easy to create an application from an existing component library, because the components use the unified interface defined by the framework, so that communication between components is simple.
The framework can reuse the design. It provides reusable abstract algorithms and high-level designs, can break down large systems into smaller components, and can describe internal interfaces between components. These standard interfaces make it possible to build various systems by assembling existing components. As long as the interface definition is met, the new component can be inserted into the framework, and the component designer can reuse the framework design.
The framework can also reuse analysis. If all personnel analyze transactions according to the framework, they can divide the transactions into the same components and adopt similar solutions, in this way, analysts using the same framework can communicate with each other.
The main features of using framework technology for software development include:
Good software architecture consistency in the field;
Establish a more open system;
Code reuse is greatly increased, and software production efficiency and quality are also improved;
Software designers should focus on understanding the field to make requirement analysis more adequate;
The experience is stored, so that experienced people can design frameworks and domain components without being limited to low-layer programming;
Quick prototyping technology is allowed;
It facilitates collaboration among multiple people in a project;
A large amount of reuse reduces the average development cost, speeds up development, reduces development staff, and reduces maintenance costs. The parameterized framework improves adaptability and flexibility.

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.