SAAS series 13: Architecture of SAAS System

Source: Internet
Author: User

1. System Architecture Design

In software development, the system architecture determines the stability, robustness, scalability, compatibility and availability of a system. It is the soul of the system. Architecture is the core concern of architects. A good system architecture is the beginning of a successful system. Otherwise, good code and design will not help.

2 Introduction to the main development frameworks of. net

L castle

Castle is. an open-source project of the. NET platform, from the data access framework ORM to the IOC container, to the MVC Framework and AOP at the web layer, basically covers everything in the entire development process, it provides good services for us to quickly build enterprise-level applications. Among them, the key technologies are activerecord, facilities, monorail, and so on.

Advantages: it embodies the ideas of ORM, IOC, activerecorder, and MVC framework.

Deficiency: The Framework hierarchy is unclear.

L petshop

Petshop is used by Microsoft to demonstrate. NET Enterprise system development capabilities. Petshop4.0, which is released by Microsoft for SQL Server 2005 and Visual Studio 2005. Some new technologies are used. Updates and synchronization of cached data with databases, new Web controls, Master application, asynchronous communication, and message queue. These are all very practical technologies. The abstract factory model is widely used in petshop. Because master pages, membership, and profile are used, the encoding volume at the presentation layer is reduced by 25%, and the encoding volume at the data layer is reduced by 36%.

  

Figure 1 architecture of petshop4.0

In the data access layer (DAL), petshop4.0 uses the Dal interface to abstract the data access logic and uses the Dal factory as the factory module of the data access layer object. For the Dal interface, the SQL Server Dal that supports the MS-SQL and the Oracle Dal that supports the Oracle are specific implementations, respectively. The model module contains data entity objects. We can see that the "interface-oriented programming" concept is fully adopted in the data access layer. The abstracted idal module is independent from the specific database, so that the entire data access layer facilitates database migration. The dalfactory module manages creation of Dal objects to facilitate access to the business logic layer. Both the sqlserverdal and oracledal modules implement the idal Module Interface, which contains the select, insert, update, and delete operations on the database. Because of the different database types, database operations are also different, and the code is also different.

In addition to removing the downward dependency, the abstracted idal module only has weak dependencies on the business logic layer.

Advantages: it reflects the orm and IOC ideas of the factory model and enterprise-level development of. net.

Deficiency: There is no ORM idea.

L nhib.pdf

Hibernate is currently the most widely used open-source object relationship ing framework, which is similar to ADO. net) is a lightweight object encapsulation, so that programmers can use the object programming thinking to manipulate the database as they wish. Currently, Java is quite popular in China. Nhibernate, like nunit and Nant, is implemented Based on. NET hibernate. It mainly embodies the idea of ORM, solves the problem of persistent layer in hierarchical development, and is very important in layer N development.

Advantage: it reflects the orm and persistence layer.

Insufficient: the configuration is complex and over-reliant on XML files.

Technical Summary:

Or mapping, layered architecture, castle-activerecorder, Atlas, reflection, design mode (Singleton mode, simple factory mode, policy mode), XML, IOC, and framework.

3 Introduction to the main development frameworks of J2EE

L Struts Framework

The Struts framework is an open-source product that develops Web Application Software Based on the Model-View-controller (MVC) design example. It uses and extends the Java Servlet API, initially created by Craig McClanahan. In May 2000, it was donated to the Apache Foundation. The Struts framework demonstrates a powerful custom tag library, Tiled Display, Form validation, and i18n (international ). In addition, Struts supports many description layers, including JSP, XML, and XSLT, so that Java programmers can use the object programming thinking to manipulate the database as they wish, including javaserverfaces (JSF) and velocity; some model layers, including JavaBeans and EJB, are also supported.

The following is the core content of struts:

JSP (taglib)> actionform> action> event> ejbaction> EJB> Dao> Database

JSP (taglib) (forward) <-Action <-eventresponse <――

Advantage: Based on the MVC mode, the structure is good, and Based on JSP.

Insufficient: the scalability is not good, the logic is complicated for large-scale projects, and the framework hierarchy is not clear.

L Spring framework

Spring framework is a hierarchical Java/J2EE application framework. It is designed and released based on expert one-on-one J2EE. The Spring framework provides a simple development technology for automating the processing of a large number of attribute files and assistant classes in projects.

Spring is an open-source framework created by Rod Johnson and described in his book J2EE design and development programming guide. It is created to solve the complexity of enterprise application development. Spring makes it possible to use the basic JavaBeans to accomplish the tasks previously only completed by EJB. However, spring is not only used for server-side development. From the perspective of simplicity, testability, and loose coupling, any Java application can benefit from spring.

The Spring framework has the following main features:

1. Powerful Configuration Management Based on JavaBeans, using the inversion-of-control (IOC) principle.

2. A Core Bean factory can be used in any environment, from applets to J2EE container programs.

3 The General abstraction layer is suitable for Database Transaction Management. It allows you to insert transaction managers and easily divide the boundaries of transactions without having to deal with low-level issues.

4. A very meaningful JDBC abstraction layer for exception handling.

5. Integrate with hibernate to implement Dao support and transaction policies.

Advantages: it embodies J2EE, container, lightweight, control reversal, and Aspect-oriented thinking.

Disadvantages: The structure is complex and hard to understand.

L Hibernate framework

Hibernate is an open-source object relationship ing (ORM) framework that encapsulates JDBC with lightweight objects, it provides an easy-to-use framework to map an Object-Oriented Domain Model to a traditional relational database, allowing Java programmers to manipulate the database using the object programming thinking as they wish. It not only maps data types from Java classes to database tables (and SQL data types from Java data types), but also provides data query and retrieval capabilities, and can greatly reduce the development time spent on SQL and JDBC manual data processing. The most revolutionary thing is that hibernate can replace CMP in the J2EE architecture where EJB is applied to achieve data persistence.

Hibernate aims to reduce developers' programming tasks associated with a large amount of common data persistence. Hibernate can also adapt to the development process, whether it is the initial design or from a ready-made database. Hibernate can automatically generate SQL statements, freeing developers from the tedious tasks of manually processing result sets and converting objects, and porting applications to all SQL databases. It also provides transparent persistence. The only requirement for the persistence class is to implement a non-parameter constructor.

Advantage: It is mainly used in the EJB layer and is highly configurable and flexible, which simplifies database operations.

Insufficient: difficult to configure.

4. Common Software Architecture

L three-tier architecture

In the software architecture design, hierarchical structure is the most common and important structure. The hierarchical structure is generally divided into three layers: data access layer, business logic layer (or domain layer), and presentation layer ,:

  

Figure 2 three-tier architecture

Data access layer: it is also known as the persistent layer. Its function is mainly to access the database. Simply put, select, insert, update, and delete operations on data tables are implemented. If you want to add an ORM element, it will include mapping between the object and the data table, and object Object persistence.

Business logic layer (businessrules): is the core of the entire system. It is related to the business (FIELD) of the system. Taking the STS system as an example, the design of the business logic layer is related to the sales tracking logic. It encapsulates operations on the data access layer in the structure. This layer is mainly composed of classes that implement specific business logic.

Presentation layer (webui): it is the UI part of the system and is responsible for the interaction between users and the entire system. In this layer, the ideal state should not include the business logic of the system. The logic code in the presentation layer is only related to the interface elements. In the current project, ASP. NET is used for design. Therefore, it contains many Web controls and related logic.

L five-layer architecture

The SAAs software architecture can also be divided into five layers: User Interface Layer (presentation layer), business logic layer, General layer, application framework layer, and remote access (WebService) layer, data access layer ,:

  

Figure 3 Microsoft-based. Net Architecture Design

User Interface Layer (UI)

The user interface layer is a user interface for direct operations. This layer consists of the interface appearance, Form Controls, frames, and other parts. The user interface layer is responsible for user interaction with the entire system. In this layer, the ideal state should not include the business logic of the system. The logic code in the presentation layer is only related to the interface elements. In the current project, ASP. NET is used for design. Therefore, it contains many Web controls and related logic.

2. The interface exterior includes SKIP (skin), images (image), and CSS (style sheet)

2. Form Controls include common forms and user-defined controls.

2. The framework mainly includes master page and frame page.

2. Others include JavaScript files, DLL files, report reports, schema database creation, and model development templates.

Business logic layer (businessrules)

Is the core of the entire system. It is related to the business (FIELD) of the system. Taking the STS system as an example, the design of the business logic layer is related to the sales tracking logic. It encapsulates operations on the data access layer in the structure. This layer is mainly composed of classes that implement specific business logic.

2. blfactory business logic Factory

2. IBL business logic interface

2. businessrules business logic implementation

General Layer

The general layer runs through the presentation layer and business logic layer of the entire project. It mainly stores the general definition of constants and General Services in the project. Here, the service is a general method in the business logic of the current project, we will write them in the corresponding static class. It is provided as a service.

Commonlayer: stores common constants and methods.

Data access layer

The structure of this layer is the most complex and consists of the following layers: dalfactory, idal, and persistencefacade ), the temporary layer (dataaccesslayer) and the data persistence layer (persistencelayer ).

The following is an overview:

2. persistencelayer layer, which is the bottom layer of the Framework Design (except the application framework layer ). It is mainly responsible for Using ORM to visualize physical databases. Simply put, the database table is mapped to the object class, and the corresponding field is mapped to the class attribute. In this way, the physical database is completely transparent to developers, and the idea of Using ORM is completely free from the physical database. And independent from the specific implementation of the database.

2. Implement activerecorder, a lightweight data access component under Castle, a well-known open-source project.

2. persistencefacade layer and idal. All query methods used in the project are defined here. Corresponds to the data entity defined at the persistencelayer layer. In the query class defined by these words, you can apply any combination of the three query methods provided by activerrecorder (simple interface provided by activerrecorderbase, simple query simplequery, and custom query customerquery. In addition, each class must implement the interface defined at the idal interface layer.

2. The dalfactory layer, as the data access factory, calls related operations in the data access component consisting of idal and persistencefacade through the. NET reflection mechanism.

2. dataaccesslayer temporary layer. First, it is completely unnecessary to declare this layer. Because we can not write any SQL statements in the project. All SQL statements are replaced by hql. This layer is designed to allow the technical transition of personnel in the project team. This layer can operate databases through SQL (not recommended ). This layer will not be provided after the architecture is stable.

Application Framework)

This layer aims at technological accumulation. Move common items between projects to the application framework layer for code reuse. This layer can be black-box later. It can include common components.

2. Framework: Accumulate methods and controls that can be abstracted.

2. msmqmessag: Message Processing queue implementation

2. Pager: Generic paging class

2. Report: common reports

2. Controls: control processing class

2. dataformat: data format conversion class

2. webui: page processing class

2. Validate: data verification

2. Object: conversion and access between objects

5 Advantages of Layered Architecture

1. developers can only pay attention to one of the layers in the entire structure;

2. It is easy to use new implementations for the implementation of the original hierarchy;

3. The dependency between layers can be reduced;

4. conducive to standardization;

5. facilitate the reuse of logic at each layer.

In summary, the hierarchical design can achieve the following goals: decentralized attention, loose coupling, logic reuse, and standard definition.

A good hierarchical structure can make the Division of Labor clearer for developers. Once the interfaces between different layers are defined, developers responsible for different logic designs can focus on them separately and go hand in hand. For example, the UI staff only need to consider the user interface experience and operations. The design staff in the field can only focus on the design of the business logic, and the database designers do not have to worry about tedious user interaction. Each developer's task is confirmed, and the development progress can be improved quickly.

The benefits of loose coupling are obvious. If a system is not layered, the logic of each system is closely intertwined and mutually dependent. No one can be replaced. Once a change occurs, the impact on the project is extremely serious. Reducing the dependence between layers can ensure the scalability of the future and obvious advantages in reusability. Once a unified interface is defined for each function module, it can be called by each module without repeated development for the same function.

A good hierarchical structure design is also essential. This system is scalable and replaceable only on the basis of a certain degree of standardization. The communication between layers also ensures the standardization of interfaces.

The hierarchical structure is inevitable because of the following defects:

1. Reduced system performance. This is self-evident. If the hierarchical structure is not used, many businesses can directly access the database to obtain the corresponding data, but now it must be done through the middle layer.

2. Cascade modifications may sometimes occur. This kind of modification is especially reflected in the top-down direction. If you need to add a function in the presentation layer, to ensure its design conforms to the hierarchical structure, you may need to add the corresponding code in the corresponding business logic layer and data access layer.

6. Software Architecture View

Philip kruchten wrote in his book "Introduction to the Rational Unified Process:

An architecture view is a simplified description of a system from a certain perspective or point. The description covers a specific aspect of the system, the entity irrelevant to this aspect is omitted.

That is to say, the architecture should cover too much content and decision-making, which is beyond the scope of the "one-stop" ability of the human brain. Therefore, the "divide and conquer" approach is used to design separately from different perspectives. At the same time, it also facilitates the understanding, communication and archiving of the software architecture.

  

Figure 4 4 + 1 view method proposed by Philip kruchten

Different architecture views of this method bear different architectural design decisions and support different objectives and purposes:

L logical view: When the object-oriented design method is adopted, the logical view is the object model.

L Development View: Describes the static organization of the software in the development environment.

L processing view: describes the design of system concurrency and synchronization.

L physical view: describes how the software maps to the hardware, reflecting the system's distributed design.

  

Figure 5 Architecture Design Based on different requirements using the 4 + 1 View

Logic view. The focus on Functions of the logical view includes not only user-visible functions, but also the "auxiliary function modules" that must be provided to implement user functions. They may be logical layers and functional modules.

Development View. The development view focuses on packages, including not only source programs to be compiled, but also third-party sdks, ready-made frameworks, and class libraries that can be directly used, and the system software or middleware on which the developed system runs. There may be a certain ing relationship between the Development View and the logical view. For example, the logical layer is usually mapped to multiple packages.

Processing view. The processing view focuses on processes, threads, objects, and other runtime concepts, as well as related concurrency, synchronization, and communication issues. Relationship between the processing view and the development view: the development view focuses on the static dependency of the package during the compilation period. After these programs run, they will be represented as objects, threads, and processes, the view processing focuses on the interaction of these runtime units.

Physical view. The physical view focuses on how to install or deploy the target program and its dependent runtime libraries and system software to the physical machine, and how to deploy machines and networks to meet the reliability and scalability requirements of software systems. Relationship between the physical view and the processing view: the processing view focuses on the dynamic execution of the target program, while the physical view focuses on the static location of the target program; the physical view is an architectural view that comprehensively considers the interaction between the software system and the entire IT system.

7. Summary

This article introduces the architecture design method of SAAS. By introducing the main development frameworks of. Net and the main development frameworks of J2EE, you can analyze their respective advantages and disadvantages.

At the same time, we introduced the hierarchical mode of the software architecture, and embodied the core value of the software architecture through specific layers. The architecture model can be applied in our development.

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.