多维视图和质量目标

MultiDimensionalSoftwareViews

ThreeDimension

Build-time Views

Build-time(构造阶段):idea -> requirement -> design -> code -> installable / executable package

Code-level view(代码的逻辑组织):source code -- how source code are logically organized by basic program blocks such as functions(函数), classes(类), methods(方法), interfaces(接口).

Component-level view(代码的物理组织):architecture -- how source code are physically organized by files(文件), directories(目录), packages(包), libraries(库).

Moment view:what do source code and component look like in a specific time

Period view: how do they evolve/change along with time

Build-time, moment, and code-level view

  • 词汇层面:Lexical-oriented source code
  • 语法层面:Syntax-oriented program structure: e.g. Abstract Syntax Tree (AST)
  • 语义层面:Semantics-oriented program structure: e.g. Class Diagram

AST:彻底结构化,将源代码变为一棵树,对树做各种操作==对源代码的修改.

AST

Class Diagram (UML):describe interfaces, classes, attributes, methods, and relationships among them.

UML

Build-time, period, and code-level view

  • Code churm(代码变化)

Build-time, moment, and component-level view

  • file, package, library
  • Static linking
  • Test Case
  • build sript(component diagram) 构建脚本(组件图)

Source code (physically organize)-> files (organized by directories/ encapsulated) -> packages -> logically components and sub-systems(组件和子系统).

Reusable modules(可重用模块) are in the form of libraries(库).Libraries are stored in disk files(磁盘文件).Sources of libraries: OS pre-installed set/ language SDK/ third-party sources/ developers' own published libraries.

When a program is edited, built and installed, a list of libraries to search must be provided.(编程、build和安装时,需要提供库路径)。Two approaches integrating a library into program: Static or Dynamic linking.

Static linking:静态链接发生在构造阶段(build time), 库被拷贝进入代码形成整体,执行的时候无需提供库文件.

Dynamic linking:build time 仅仅做出标记,Runtime根据标记转载至内存与主程序关联。

Build-time, period, and component-level view

How files/packeages/components/libraries change.

  • Software Configuration Item (SCI,配置项)
  • Version (版本)

Runtime views

Runtime(运行阶段): 程序被载入目标机器以及目标机器所需磁盘文件

Code-level view: 代码层面 -- 逻辑实体(程序)在内存中如何呈现,程序单元(函数、对象等)交互情况

Component-level view: 构件层面 -- 物理实体在物理硬件环境中如何呈现和交互?

Moment view: 逻辑/物理实体在内存/硬件环境中特定时刻的形态如何?

Period view: 逻辑/物理实体在内存/硬件环境中的形态随时间如何变化

High-level concepts of run-time software

  • Executable programs (可执行程序):CPU执行的机器可读指令
  • Libraries
  • Configuration and data files (配置和数据文件) that the program can load from disk
  • Distributed programs (分布式程序):多进程
  • Native Machine Code (原生机器码)
  • Full Program Interpretation (程序完全解释执行)
  • Interpreted Byte Codes (解释型字节码)

Run-time, moment, and code-level view

  • Code Snapshot
  • Memory dump (内存信息转储)

Snapshot Diagram:程序运行时内存里变量层面的状态。

SnapshotDiagram1

Run-time, period and code-level view

  • Execution tracing (执行跟踪):用日志方式记录程序执行的调用次序。
  • Concurrent multi-threads (并发多线程)

Run-time, moment, and component-level view

Run-time, period, and component-level view

  • Event log (事件日志)
  • Multi-processes (多进程)
  • Distributed processes (分布式进程)
EventLogAndExecutionTracing

Transformation between views

TransformationBetweenViews

类、属性、方法

  Programming / Coding (ADT抽象数据类型 /OOP面向对象的程序设计)

  Review, static analysis/checking

模块化

  Design (ADT/OOP; Reusability; Maintainability)

  Build: compile, static link, package, install, etc

创建于运行

  Install / deploy

  Debug, unit/integration testing (Robustness and Correctness) 测试

瞬时与周期

  Version control

  Loading, dynamic linking, execution (dumping, profiling, logging)

  Concurrent threads


Quality properties of software systems (软件系统的质量)

External quality factors affect users. 外部质量影响用户

Internal quality factors affect the software itself and its developers. 内部质量因素 影响 软件本身和它的开发者

External quality results from internal quality. 外部质量取决于内部质量,最终外部质量才最重要

外部质量因素

外部质量因素:速度或易用性等质量,被用户检查

  1. Correctness (正确性): 输入输出正确,按定义的规约 (specification)执行,这是软件开发最重要的因素。

    • 测试和调试 (Testing and debugging):发现不正确、消除不正确
    • 防御式编程 (Defensive programming):在写程序的时候就确保正确性 (e.g. typing and assertions)
    • 形式化方法 (Formal approach):通过形式化验证发现问题
  2. Robustness (健壮性): 健壮性是针对异常情况的处理,出现异常(abnormal conditions)时不要“崩溃”

    • 未被specification覆盖的情况即为"异常情况"
    • "narmal"和"abnormal"是主观而非客观的
    • 产生错误信息,干净终止执行,进入“优雅”模式
    • 出现规约定义之外的情形的时候,软件要做出恰当的反应
    RobustnessVSCorrectness
  3. Extendibility (可扩展性): 适应规约变化的容易程度。 要便于软件功能的增加/扩展(ADT、OOP、留下一个Visitor),降低未来修改软件时的成本。

    • Design simplicity (简约主义设计)
    • Decentralization (分离主义设计):模块化
  4. Reusability (可复用性): 一次开发,多次使用,寻找共性,未来直接使用现在的这段代码。

  5. Compatibility (兼容性): 不同的软件系统之间相互可容易的集成。

    • 保持设计的同构性
    • 兼容性的关键是标准化,特别是标准协议。
  6. Efficiency (性能): 。

    • 性能毫无意义,除非有足够的正确性
    • 对性能的关注要与其他质量属性进行折中
    • 过度的优化导致软件不再适应变化和复用
    • 不要过早的优化,性能在没有正确性保障的条件下是没有意义的
    • 性能和其他质量目标冲突,折中处理
  7. Portability (可移植性): 软件可方便地在不同的技术环境之间移植。

    • 硬件、操作系统
  8. Ease of use (易用性): 容易学、安装、操作、监控,给用户提供详细的指南。

    • Structural simplicity (结构简单): 易于学习使用
    • Know the user: understand the system’s intended user community
  9. Functionality (功能性): 功能过多程序复杂、不灵活、占用过多的磁盘空间,会导致易用性的降低。

    • 每增加一小点功能,都确保其他质量属性不受到损失
    • 主要功能要首要提升质量 OsmondCurves
  10. Timeliness (及时性): 软件要能够在用户需要甚至之前,能及时地设计出来。

  11. Other qualities: Verifiability (可验证性), Integrity (完整性), Repairability (可修复性), Economy (经济性)。


内部质量因素

内部质量因素:软件产品品质,如模块化和可读性,开发人员才能察觉

  • 代码行数 (LOC)、圈复杂度 (Cyclomatic Complexity)
    • Complexity 是外部因素的 enemy
  • 构架相关因素:耦合 (coupling)、内聚 (cohesion)
  • 可读性 (Readability)
  • 可理解性 (Understandability)
  • 整洁度 (Clearness)
  • 大小 (Size)

Tradeoff between quality properties (折中、妥协)

tradeoff

以上这些质量属性之间往往不能兼得,需要权衡,某些特定要求下可以放弃优化其他项而优化另一项。

正确的软件开发过程中,开发者应该将不同质量因素之间如何做出折中的设计决策和标准明确的写下来。

正确性是绝不能与其他质量因素折中的.

OOPimprovesQuality五个关键的质量指标

FiveKeyQualityObjectives