Some Thoughts on Software Architecture Design-General Architecture Design Model

Source: Internet
Author: User

Recently, I have begun to design a Service Release and governance framework. I have some experiences with the code of several mainstream frameworks, such as Alibaba Dubbo, netty at the transport layer, and tomcat at the container layer.


The classic object-oriented analysis and design book explains why design is divided by hierarchy and the advantages of reading books and summarizing so many frameworks, there are some basic architecture design patterns that can be grasped.

General designs, especially large frameworks, can be divided into four layers:Interface Layer, abstraction layer, process implementation and adaptation layer, specific implementation Layer.


The interface layer defines the functions of the entire framework. It is best to use interfaces instead of abstract classes.. The scalability of interfaces is better than that of abstract classes. Thrift uses abstract classes to design top-level functions. It is very difficult to extend thrift later.

There are some key points about the interface layer design:

1. The interface granularity should be small. Refer to the single responsibility principle.

2. Use a large interface to adapt to multiple small interfaces, instead of designing a large interface. The scalability of small interfaces is better than that of large interfaces.

3. The interface design only needs to consider the functions to be available, do not need to consider the attributes of the class, how to implement and so on, these extensions at the abstraction layer and Implementation Layer


The abstract layer defines the abstract classes that implement interfaces. They are all implemented using abstract classes., The main functions include:

1. provide default implementation for the interface

2. Provides New abstract method extension Interfaces

3. Provide public attributes and methods for subclass

4.For example, define the basic call ProcessThis is especially important when designing large-scale frameworks and implementing the underlying layer with a third party. Reference template Mode


Process implementation and Adaptation LayerThis layer is implemented by common classes and inherits the abstract layer. The main functions are as follows:

1. Implement abstract methods defined at the abstraction layer and Interface Layer

2.Define the process for calling the framework

3. If the underlying layer uses a third-party frameworkAdaptation and decoration layer, Refer to adapter mode and decorator Mode


The specific implementation layer uses common classes for implementation,It mainly implements specific functions, but does not participate in the framework call process..


The layer-4 structure is a scalable, robust design, interface layer defining function, abstraction layer and process implementation and Adaptation Layer defining the framework calling process, the specific implementation layer is pluggable and can be implemented in multiple ways.


The actual design can be tailored Based on the functions to be implemented by the framework. For example, layers 3 and 4 can be merged without multiple implementations. If Dubbo is a framework that supports multiple transport and protocol layers at the underlying layer, a complete 4-layer structure is required, and the abstract layer and process layer must be well designed, because the specific transfer of the framework is in these two layers, the actual third-party implementation will be called only when the underlying layer is involved.








Some Thoughts on Software Architecture Design-General Architecture Design Model

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.