软件构造三方面
one | two |
---|---|
Build-time | Run-time |
Moment | Period |
Code-level | Component-level |
Code-level注重代码底层是如何组建的,Component-level注重于组件之间的结构
Moment注重于某一时刻的状态 Period注重于在一段时间内的变化
三者两两组合共有8种情况如下图所示,下面来分别分析。
构造时刻
BMCD
在逻辑上代码是如何通过基本程序块组成的,分为三个方面
(1)面向词法
(2)面向语法
(3)面向语义
面向语法使用AST,面向语义一般结合UML和类图的形式
BPCD
描述代码随着时间的变化
BMCP
源代码被组织成文件,文件被封装成为包、组件子系统,可复用模块形成类库。
类库分为:OS预装类库、语言自带类库、第三方类库和自行开发的。
类库的连接方式有两种一种为动态链接一种为静态链接,静态链接是将类库文件复制到可执行文件中,成为可执行文件的一部分;
BPCP
主要注重软件的一些组件随着时间的变化。软件版本的变化是由构成软件的组件版本变化导致的。
版本控制是给计算机软件的不同状态分配唯一的名字或者编号的过程。软件演化是软件产生之后,由于不同的原因对其进行持续地升级过程。软件工程很大的消耗都是在于后期的维护升级等。
运行时刻
一种是代码完全转换为CPU能识别的机器码,另一种是把源代码加载入内存中进行解释执行。还有的程序被编译成字节码形式,运行时需要由解析器转换成机器码或者解释执行。Per 或者 Python在执行时先被编译为字节码再解释执行。
动态链接不将目标文件复制到可执行程序中,只是标注需要的,在运行时,加载用到的库到内存中,然后和主程序链接,部署时需要将用到的类库同程序一起部署。类库变化时,不需要重新生成可执行程序,多个运行中程序可共享同一类库,优化内存使用
RMCD
Snapshot diagram 刻画内存中某时刻变量状态
memory dump A memory dump is the process of taking all information content in RAM and writing it to a storage drive. 可以帮助开发者找到错误信息,修改BUG
RPCD
Sequence diagram UML
A sequence diagram shows object interactions arranged in time sequence. It depicts the objects and classes involved in the scenario and the sequence of messages exchanged between the objects needed to carry out the functionality of the scenario. Sequence diagrams are typically associated with use case realizations in the Logical View of the system under development. Sequence diagrams are sometimes called event diagrams or event scenarios.
A sequence diagram shows, as parallel vertical lines (lifelines), different processes or objects that live simultaneously, and, as horizontal arrows, the messages exchanged between them, in the order in which they occur. This allows the specification of simple runtime scenarios in a graphical manner.(Wikipedia)
Execution tracing
Tracing involves a specialized use of logging to record information about a program’s execution. This information can help debug.
RMCP
A UML deployment diagram is a diagram that shows the configuration of run time processing nodes and the components that live on them. Deployment diagrams is a kind of structure diagram used in modeling the physical aspects of an object-oriented system. They are often be used to model the static deployment view of a system (topology of the hardware).
RPCP
Event log 给系统管理者提供诊断和审计的有用信息。与Execution tracing相比,Event log 更易懂,更加宏观,清晰。