自消息(非递归)与自递归消息 [英] self message(non recursive) vs self recursive message

查看:41
本文介绍了自消息(非递归)与自递归消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这两条消息有什么区别?我在网上搜索了一下,我能找到的大部分是

What is the difference of these two messages? I searched the web a bit and most what I could find is

自身消息是对象发送给自身的消息.它是一条消息,表示调用同一生命线的消息.self 消息可以表示操作的递归调用,或者一种方法调用属于同一对象的另一种方法.

A self message is a message that an object sends to itself. It is a message that represents the invocation of message of the same lifeline. A self message can represent a recursive call of an operation, or one method calling another method belonging to the same object.

递归消息带来的额外激活栏有什么好处?

What is the benefit of additional activation bar that recursive message brings?

在图形符号中:

非递归自我消息:

递归自我消息

有什么区别?

推荐答案

当您调用类中的函数时,您应该使用 self 消息,这些函数要么不调用其他函数,要么不发送任何消息(或但您不想在序列中显示此内容).

You should use a self message when you are calling functions in the class which either don't call other functions, don't send any messages (or they do but you don't want to show this in the sequence).

如果您还想对类的内部函数如何与其他生命线交互进行建模,则必须使用递归调用来显示这一点,否则读者无法知道消息是从内部函数发送/接收的.

If you also want to model how the inner functions of the class interact with other lifelines, you have to use recursive calls to show this, otherwise the reader can't know that the messages are sent/received from the inner function.

这篇关于自消息(非递归)与自递归消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆