如何在序列图中表示对超类的调用?
为了说明目的,我有一个可以表示的复杂对象层次结构, 像这样:
class Base {
public handle() {
//base handling code
onHandlingDone()
}
public onHandlingDone() {
//base onHandlingDone code
}
}
//--------------------------------------
class Regular extends Base {
public handle() {
super.handle();
//regular handling code
}
public onHandlingDone() {
//regular onHandlingDone code
super.onHandlingDone()
}
//--------------------------------------
}
class Special extends Regular {
public handle() {
super.handle();
//special handling code
}
public onHandlingDone() {
//special onHandlingDone code
super.onHandlingDone()
}
}
注意:这不是我的设计,我正在对一个巨大的项目进行维护。有很多“特殊”实施。重构不是一个选择。
有很多交错的代码:方法正在调用超类方法,而这些方法也是超类方法,并且某些调用是在每个级别上完成的。
现在我想画一些序列图来帮助我理解发生了什么。
我应该如何在层次结构中表示这些调用?
- 展开层次结构会在图表中添加大量噪音,但会很准确。
- 屏蔽层次结构将导致一个更简单的图表,但它很混乱(那个该死的方法又在哪里,当我发送此消息时我在层次结构中的哪里?)
有没有任何常用的方法来处理这种复杂的类层次结构在序列图中?
I have a complex hierarchy of objects that we can represent, for illustration purpose,
like that:
class Base {
public handle() {
//base handling code
onHandlingDone()
}
public onHandlingDone() {
//base onHandlingDone code
}
}
//--------------------------------------
class Regular extends Base {
public handle() {
super.handle();
//regular handling code
}
public onHandlingDone() {
//regular onHandlingDone code
super.onHandlingDone()
}
//--------------------------------------
}
class Special extends Regular {
public handle() {
super.handle();
//special handling code
}
public onHandlingDone() {
//special onHandlingDone code
super.onHandlingDone()
}
}
Note: this is not my Design, I'm doing maintenance on a huge project. There are a lots of 'Special' implementation. Refactoring is not an option.
There is a lot of interleaved code: method are calling super class methods that are also super class method, and some call are to other methods are done at each level.
Now I want to draw some sequence diagram to help me understand what is going on.
How should I represent these calls across the hierarchy ?
- Unrolling the hierarchy would add lots of noise in the diagram, but will be accurate.
- Masking the hierarchy will result in a simpler diagram, but it is confusing (where is that damn method again, where in the hierarchy am I when I send this message ?)
Is there any usual way to deal with this kind of complex class hierarchy in sequence digram ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您展开层次结构并具有超级->常规->基础泳道,则可以执行此操作。然而,最小化噪音的一种方法是制作一个 super 构造型,而不是使用 self 调用。
You could do this if you unroll the hierarchy and have swim lanes for the Super->Regular->Base. However one way to minimise the noise would be to make a super stereotype instead of using self calls.