惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 数字冰块

VS2005 中文版的翻译 - 数字冰块 - 博客园 关于使用 EnumWindows 枚举应用程序窗口的技巧 微软亚洲研究院夏令营记 软件学院学习体验之三 关于权限模型 .netcpu?!见过了吗? 着手准备开源桌面 Blog 软件 一定要记住:Page.IsPostBack 不能忘。。。 软件学院学习体验之二 VS.NET 服务器资源管理器、Smartphone 模拟器中的程序调试、虚拟网卡、Smartphone 设备上的程序调试及其他。 软件学院学习体验之一 啥叫“Functional Programming ”??? 一个奇怪的问题 什么是高质量的代码? C#中的析构函数 关于.NET异步调用的初步总结 毕业了。。。 两年以后重读了一篇文章,写了点东西。 微软的宣传图片
Requirements Analysis with 'pseud-Formal' Method
数字冰块 · 2006-01-23 · via 博客园 - 数字冰块

需求开发在软件开发流程中的地位与日俱增,本文的编写目的在于介绍一种用于需求开发的子过程——需求分析的“伪形式化”方法。
本文内容在需求开发中所处的位置:
需求开发
——需求获取
——需求分析
——需求验证

需求分析阶段中,往往需要确定系统边界、接口模型、信息流等内容,需要开发系统原型 ( Prototype ) ,需要建立一个总体模型。在目前广泛应用的方法中,这些内容往往采用了自然语言描述和一些图来表示,如 Data Flow Diagram, Context Diagram 等。这样的方法有一定的模糊性,并且其后的 Design 可能与 Requirements 发生不一致。下面两张图给出了使用“伪形式化”方法的工作流程以及模型组成。

在“伪形式化”的方法中,一个完整的需求分为两大块,其一是 Initial Requirements ,其二是 Functional Spec。在 Initial Requirements 中的基本任务是:将客户需要及约束文档化,使用 Informal Goal Hierarchy 表达客户的需要,使用非形式化的语句描述约束(包含资源,性能,环境等等),对相关系统属性进行建模,通过 Formal Environment Model 标准化需求等等。而 Functional Spec 则提供一个精确的目标系统行为的黑箱模型。Initial Requirements 与 Functional Spec 的区别如下:
Initial Requirements 是针对项目发起组织的产物,它使用客户域的词汇描述客户需要,它被当作 RFP (Request for Proposal) 使用。
Functional Spec 是针对项目开发组织的产物,它使用问题域 (Problem Domain) 与软件域 (Software Domain) 的词汇描述客户的问题(包含一些目标及约束),它被当作 RFP 的回应。

这里有必要阐明几个概念。
第一个概念是 Logic 及其表达。这里的 Logic 表达牵涉到了一种逻辑符号。之所以使用逻辑符号而非自然语言,就在于逻辑符号可以更加精确的表达需求,带来更加少的逻辑错误,并且提供了一种比编程语言更加原始的表达方式。举一个例子:在一个电梯控制系统中,客户要求:

"The doors must not be open on a given floor unless the elevator is stopped at that floor." 

这句话往往就是作为规范写入我们的文档中的。而如果采用 Logic 的形式,那么就可能是类似于以下的样子:

e: an elevator, f: a floor.
Position(e
, f) means e is at the f floor
Stopped(e) means e is stopped
Door_Open(e
, f) means e’s door is open on 
the floor f   
ALL(e: elevator
, f: floor:: (Door_Open(e, f) =>
(Position(e
, f) & Stopped(e)) ))

这种描述很类似于离散数学中的逻辑表达,比起前一种各人有各人理解的自然语言描述来,这是极为精确的,没有二义性可言的。以下是三种表达的例子,分别是自然语言,逻辑表达以及我们这里所用到的表达方式。

第二个概念是 Environment Model。顾名思义,这个 Model 定义的是目标系统与参与者和系统环境之间的关系,其最终也可通过 Context Diagram 反映出来。以下是一个例子:
一个航空售票系统的 Initial Environment Model

  DEFINITION airline_environment

  INHERIT system  --  defines software_system, proposed.

--  controls

INHERIT user  --  defines User_class, uses

INHERIT business  --  defines vendor, customer, sells

IMPORT Subtype FROM type

CONCEPT airline_reservation_system: software_system

  WHERE proposed (airline_reservation_system),

        --We are going to build an airline reservation

-- system

     Controls (airline_reservation_system, reservation)

       --The system will help travel agents sell tickets by

       --managing reservations.

CONCEPT travel_agent: User_class

  WHERE ALL(ta: travel_agent

::uses(ta, airline_reservation_system)),

        --Travel agents use the airline reservation system.

        --We are only concerned with the travel agents using

        --our system.

Subtype(travel_agent, vendor),

--A travel agent is a sales person.

ALL(t : ticket :: SOME (ta: travel_agent

:: sells(ta, t) )),

    ALL(r: reservation :: SOME (ta: travel_agent

      :: supplies(ta, t) ))

--Travel agents are the only sources for tickets

--and reservations.

CONCEPT ticket: type

   WHERE Subtype(ticket, product),

      ALL (t: trip :: Needed_for(ticket, t))

--A ticket is needed for every trip.

CONCEPT trip : type

   WHERE Subtype (trip, activity),

      ALL(t: trip :: Needed_for (flight, t))

--A flight is needed for every trip.

CONCEPT passenger : type

WHERE Subtype (passenger ,custom),

      ALL (p: passenger :: SOME(t: trip :: wants(p, t))),

ALL (p: passenger :: SOME(t: ticket :: buys(p, t)))

CONCEPT airline : type

WHERE Subtype(airline, supplier),

      ALL(f: flight :: SOME(a: airline :: supplies(a, f)))

        --Every flight is associated with an airline.

        --We are only concerned with commercial flights.

CONCEPT flight :type

WHERE Subtype(flight, activity)

CONCEPT reservation : type

WHERE ALL (t: trip :: SOME(r: reservation

 :: Neded_for (r, t)))

END

经过精化 (Refine) 之后的一个 Environment Model

DEFINITION flight_view
INHERIT time
INHERIT location
IMPORT Subtype FROM type
IMPORT One_to_one FROM function (flight
, flight_id)

CONCEPT flight: type
    - -The passenger will choose a flight based on origin
,
    - -destination
, departure, arrival, and price.
WHERE Subtype (flight
, activity)

  CONCEPT origin (f: flight) VALUE (a: airport)
CONCEPT destination (f: flight) VALUE (a: airport)
CONCEPT departure (f: flight) VALUE (t: time_of_day)
CONCEPT arrival (f: flight) VALUE (t: time_of_day)
CONCEPT price (f: flight) VALUE (m: money)
CONCEPT id (f: flight) VALUE (i: flight_id)
   - - The flight id is used by the passenger to find
   - - the flight.
   WHERE One_to_one (id)   - - The id uniquely identifies
                           - - a flight.

CONCEPT airport: type
   WHERE Subtype (airport
, location)

CONCEPT flight_id: type

CONCEPT airline: type 
   WHERE Subtype (airline
, supplier),
      ALL (f: flight :: SOME (a: airline :: supplies (a
, f) ) )
        - - Every flight is associated with an airline.
        - -We are only concerned with commercial flights.
END

第三个概念是 Functional Spec 中的 FUNCTION、MACHINE、TYPE。这些东西用于定义系统中的各个模块。FUNCTION 表示变量域与值域存在的映射关系;MACHINE 表示一个状态机;TYPE 表示一种可有多个实例的类型。它们的定义语法如下:

FUNCTION function_name
--inherit 
, import , export section
--message definitions
--concept definitions
END

MACHINE machine_name
--inherit 
, import , export section
--state model definition
--message definitions
--concept definitions
END

TYPE type_name
--inherit 
, import , export section
--instance model definition
--message definitions
--concept definitions
END

以下是一个 FUNCTION 的例子:

FUNCTION square_root {precision:real SUCH THAT precision > 0.0}
    MESSAGE(x:real) - - anonymous message
        WHEN x >
= 0.0 - -  precondition
            REPLY(y:real) - - return value
            WHERE Y >
= 0.0 AND                         approximate(y*y,x)
            OTHERWISE REPLY EXCEPTION
                imaginary_square_root
CONCEPT approximate(r1
,r2:real)
    - - true if r1 is a sufficiently accurate approximation of r2
, based on the value of the precision specified by the user
    VALUE(b: boolean )
        WHERE
            babs(r1-r2)<
=abs(r2*precision)
END

可以看到,通过这种方式精确定义了一个功能模块的“黑箱”行为。

第四个概念 Stimulus-Response Diagram。这个 Diagram 用于显示以上三种 Spec Language 的输入、输出流。对于上面的实例 FUNCTION ,有下面的图:

限于篇幅以及个人的理解,目前就写这些。给出一个 Case Study ,供有兴趣的朋友学习。