软件构造 | Designing Specification

软件构造 | Designing Specification

1 Functions & methods in programming languages

在这里插入图片描述

“方法”是程序的“积木”,可以被独立开发、测试、复用使用“方法”的客户端,无需了解方法内部具体如何工作—“抽象”。

A complete method

在这里插入图片描述

2 Specification: Programming for communication

Documenting in programming

在这里插入图片描述

Specification and Contract (of a method)

  • Specifications are the linchpin 关键 of teamwork:没规约,没法分派任务,无法写程序;即使写出来,也不 知道对错。

  • The specification acts as a contract 契约: 程序与客户端之间达成的一致。

  • Spec给“供需双 方”都确定了责任,在调用的时候双方都要遵守

Why specifications?

Reality:很多bug来自于 双方之间的误解,不写下来,那么不同开发者的理解 就可能不同,没有规约 ,难以定位错误

Advantages:精确的规约,有助于区分责任,客户端无需阅读被调用函数的代码,只需理解spec即可.

An example of specification A method add() of a Java class BigInteger

在这里插入图片描述

Specifications in Java

在这里插入图片描述

Specification (contract)

在这里插入图片描述

3 Designing specifications

Stronger vs. weaker specs

在这里插入图片描述
更强的规约,表达为更小的区域

在这里插入图片描述

  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值