[系分] Function Model

本文介绍了如何使用系统顺序图(System Sequence Diagram)来描述应用对系统的功能需求,并通过操作契约(Operation Contracts)定义数据变化。文章提供了电影售票系统的具体实例,包括注册、登录及预定等流程的系统顺序图绘制要点。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

知识点:

系统顺序图:学会使用系统顺序图 (System Sequence Diagram) 描述应用对系统的功能需要。

操作契约:使用操作契约(Operation contracts)描述数据的变化。

对于用例的一个特定场景(一般是一个用例),外部参与者产生的事件,其顺序和系统之类的事件。该图强调的是从参与者到系统的跨越系统边界的事件。也就是说系统被视为黑盒


注意:一般只需用到简单消息和返回消息,SSD不超过5个消息,尽可能简单


绘图要点:

1.不应该超过5个消息

2.后置条件借用注释写在后面

例子:

(以电影售票系统为例)

注册模型:


登录模型:



预定模型:



部分操作契约如下:

契约 CO1: enterRegisterInfo

操作:enterRegisterInfo(name: String, password: String, e-mail: String)

交叉引用: 用例:用户注册

前置条件: 无

后置条件:创建了一个新customer账号,将该账号信息写入系统数据库中。


契约 CO2:confirmReservation

操作: confirmReservation(reservation: boolean)

交叉引用:用例:用户确认电影票订单
前置条件:用户正在确认订单
后置条件:系统确认订单并且在数据库中将该订单状态改为已确认。



### Function Calling Models Series in Programming and Software Development In programming languages, function calling models define how functions or procedures interact within a program. These interactions include passing arguments to the called function, executing the code associated with that function, and returning control (and possibly results) back to the caller. #### Call by Value Model The call-by-value model involves copying actual argument values into corresponding formal parameters when invoking a function. This means any changes made inside the function do not affect variables outside it because only copies were modified[^1]. ```c++ void modifyValue(int x){ x += 5; } int main(){ int num = 10; modifyValue(num); // num remains unchanged at this point. } ``` #### Call by Reference Model Conversely, under the call-by-reference scheme, instead of making copies, references pointing directly to original variable locations get passed along during invocation. Therefore, modifications performed internally will reflect externally after execution completes. ```cpp void swapValues(int &a, int &b){ int temp = a; a = b; b = temp; } int main(){ int firstNum = 20, secondNum=30; swapValues(firstNum ,secondNum ); // Values have been swapped here. } ``` #### Higher-order Functions in Functional Programming Higher-order functions represent one key aspect where functional programming excels over traditional paradigms regarding function calls. Such constructs allow treating other functions as inputs/outputs while preserving immutability principles through pure computations without side effects. For instance: ```haskell applyTwice :: (a -> a) -> a -> a applyTwice f x = f (f x) doubleMe :: Int -> Int doubleMe n = n * 2 result = applyTwice doubleMe 7 -- result equals 28 ``` --related questions-- 1. What advantages does using higher-order functions offer compared to conventional procedural approaches? 2. How can understanding different parameter-passing mechanisms improve debugging efficiency? 3. Can you provide examples demonstrating both benefits and limitations inherent in each type mentioned above? 4. In what scenarios might developers prefer call-by-name semantics versus those discussed earlier?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值