Software Architecture

Overview

主题

  • 介绍软件体系结构的基本概念
  • 当前流行的软件设计开发方法
  • 基于Spring框架的软件设计和开发

Architecture

Architecture defined

  • The art or science of building or constructing edifices of any kind for human use
  • The action or process of building
  • The special method of ‘style’ in accordance with which the details of the structure and ornamentation of a building are arranged
  • The conceptual structure and overall logical organization of a computer or computer-based system from the point of view of its use or design; a particular realization of this

Software Artifacts

Our civilization runs on software.

-Bjarne Stroustrup(比雅尼·斯特劳斯特鲁普)

软件危机(Software Crisis)

  • 1968年,联邦德国,NATO科技委员会
    • 成本不断提高
    • 开发进度难以控制
    • 质量低下
    • 维护困难
    • 用户难以满意
    • 软件生产率赶不上硬件发展和用户需求增长

Software is

  • Buggy
  • Unreliable
  • Forever changing
  • Unwarrantable
- Dvaid Parnas

Unsuitability of Software

  • U.S. Army study of Federal projects
    • 47% delivered, but not used
    • 29% paid for, but not delivered
    • 19% abandoned or reworked
    • 3% used after changes
    • 2% used as delivered

软件工程:软件危机的解决之道

  • 软件工程一门研究如何用系统化、规范化、数量化等工程原则和方法去进行软件的开发和维护的学科
    • 软件开发技术
      • 开发方法学 / 软件工具 / 软件工程环境
    • 软件项目管理
      • 项目估算 / 进度控制 / 人员组织 / 项目计划

开发软件还是很难

Software architecture

  • 随着软件系统规模越来越大、越来越复杂,整个系统的结构和规格说明显得越来越重要
  • 对于大规模的复杂软件系统来说,对总体的系统结构设计和规格说明比起对计算的算法和数据结构的选择已变得明显重要得多
  • 对于软件体系结构的系统、深入的研究将会成为提高软件生产率和解决软件维护问题的新的最有希望的途径
  • 对于软件体系结构的研究成为了最新的研究方向和独立学科分支

Software architecture defined

The software architecture of a program or computing system is the structure or structures of the system, which comprise software elements, the externally visible properties of those elements, and the relationships among them.


-- Clements et al., 1997

Some other definitions

  • Perry and Wolf, 1992
    • A set of architectural elements that have a particular form
  • Boehm et al., 1995
    • A software system architecture comprises
      • A collection of components, connections, and constraints
      • A collection of system stakeholders' need statements
      • A rationale which demonstrates that those components, connections and constraints would satisfy stakeholders' need statements

My favorite one

Architecture is a subjective thing, a shared understanding of a system’s design by the expert developers on a project. Commonly this shared understanding is in the form of the major components of the system and how they interact. It’s also about decisions, in that it’s the decisions that developers wish they could get right early on because they’re perceived as hard to change.


-- Martin Fowler, 2003

架构师

架构师实际上就是软件的总体设计师。首席设计师就是总设计师,打个通俗的比方:邓小平是中国改革开放的总设计师,我们用现在的说法可以讲,邓小平是中国改革开放的首席架构师。


-- 百度百科

架构层设计

在计算的算法和数据结构之外,设计并确定系统整体结构

  • 总体组织结构和全局控制结构
  • 通信、同步和数据访问的协议
  • 设计元素的功能分配
  • 物理分布与性能
  • 备选设计的选择

Why is SA important?


  • Communication among stakeholders
  • Early design decisions
  • Transferable abstraction of a system

软件开发组织的一种核心财富

Communication among stakeholders

Stakeholders

Each stakeholder of a software system is concerned with different system characteristics that are affected by the architecture.

  • user - is the system reliable and available when needed?
  • customer - can the architecture be implemented on schedule and to budget?
  • manager - will that the architecture allow teams to work largely independently, interacting in disciplined and controlled ways?
  • architect - will the strategies to achieve all of those goals?

“mis-communication”

Earliest design decisions

Software architecture

  • Defines constraints on implementation
  • Dictates organizational structure
  • Inhibits or enables a system's quality attributes
    • performance/ modifiability/security/scalability/inter-couple
  • Predicts system qualities by studying the architecture
  • Makes it easier to reason about and manage change
  • Enables more accurate cost and schedule estimates

Swedish Warship Vasa

Lessons from Vasa

  • Case studies of successful architectures crafted to satisfy demanding requirements, so as to help set the technical playing field of the day.
  • Methods to assess an architecture before any system is built from it, so as to mitigate the risks associated with launching unprecedented designs.
  • Techniques for incremental architecture-based development, so as to uncover design flaws before it is too late to correct them.

Transferable abstraction of a system

An architectural design codifies specific knowledge collected from experience in a domain and good designs are noted as patterns

  • To follow in developing software systems
  • To achieve specific properties
  • To solve the design problems effectively and elegantly

Patterns

A pattern is a solution to a problem in a context

  • Blackboard
  • Client-server (2-tier, 3-tier, n-tier)
  • Component-based
  • Event-driven (or Implicit invocation)
  • Layered (or Multilayered architecture)
  • Monolithic application
  • Peer-to-peer (P2P)

Patterns (continued)

  • Pipes and filters
  • Plug-ins
  • Representational state transfer (REST)
  • Rule-based
  • Service-oriented architecture and microservices
  • Shared nothing architecture
  • Space-based architecture

Example: Model-View-Controller

  • Context
    • 人机交互界面设计
  • Problem
    • 功能的变化要求用户界面的改变
    • 平台的改变要求用户界面随之改变
    • 界面的改变需足够方便,且不应影响系统功能本身

分类

  • Architectural patterns
    • Help in structuring a software system into subsystems
  • Design patterns
    • Support the refinement of subsystems and components
  • Idioms
    • Help in implementing particular design aspects in a specific programming language

Architectural Patterns

  • Expresses a fundamental structural organization schema for software systems.
  • It provides a set of predefined subsystems, specifies their responsibilities, and includes rules and guidelines for organizing the relationships between them.
    • System-wide
    • Fundamental design decision
      • E.g. MVC provides a structure for interactive software system

研究内容

  • 体系结构分析
  • 体系结构设计
  • 软件体系结构评价方法
  • 体系结构发现
  • 体系结构演化
  • 特定领域的体系结构框架
  • 软件体系结构支持工具

aoasbook.org

Explaining SA patterns with Spring

Spring

Spring框架是Java平台的一个开源的全栈(Full-stack)应用程序框架和控制反转容器实现,一般被直接称为Spring。该框架的一些核心功能理论上可用于任何Java应用,但Spring还为基于Java企业版平台构建的Web应用提供了大量的拓展支持。Spring没有直接实现任何的编程模型,但它已经在Java社区中广为流行,基本上完全代替了企业级JavaBeans(EJB)模型。

  • 第一版由 Rod Johnson 开发,并在2002年10月发布。
  • 2003年6月,Spring Framework 第一次发布在 Apache 2.0 许可证下。
  • 2006年,Spring Framework 获得了Jolt生产力奖和JAX创新奖。

Spring Projects Covered

  • Spring Core Containers - Components and IoC
  • Spring Boot & Spring Web & Spring Mobile - MVC
  • Spring Batch - Pipes-and-filters
  • Spring Cloud - Microservices
  • Spring Cloud Function - Serverless
  • Spring Event & Spring AMQP - Event-driven
  • Spring HATEOAS - RESTFul
  • Spring Integration - Message-driven
  • Spring Webflux and Project Reactor - Responsive

---

# B站 ![height:350px](images/01-bilibili.png) ![bg right:70% fit](images/01-contents.png)