代码之家  ›  专栏  ›  技术社区  ›  Falmarri

回调函数/类的UML类建模

  •  0
  • Falmarri  · 技术社区  · 14 年前

    我不是UML方面的专家,我只是在毕业前修了一门课程,花了大量时间在UML建模上。我了解基本情况,但前几天我在做一个项目,出于我自己的好奇心,我想知道你会如何模拟回调。下面是我正在编写的代码的一部分

    
    class OnChangeHandler():
    
        def my_init(self, rem, loc):
            self.remotes = rem
            self.locals = loc
    
        def process_IN_CREATE(self, event):
            #Do some work
    
        def process_IN_MODIFY(self, event):
            #Do some other work
    
    
    
    class Watch():
        def __init__(self):
    
            self.wm = WatchManager()
            self. notifier = AsyncNotifier(self.wm, OnChangeHandler(loc=self.locals, rem=self.remotes))
    
    

    2 回复  |  直到 14 年前
        1
  •  -1
  •   UML GURU    14 年前

    为了得到类图,可以通过反转.class来反转框架。

    请参见下面的框架反转示例: http://www.ejb3.org/jar_file_reverse/jar_file_reverse.html

    http://www.ejb3.org/jar_file_reverse/jar_file_reverse.html#3.Sequence_Diagram_reverse_engineering 如果您需要添加新代码并重用现有编译代码,那么它非常有用。

    希望这有帮助。

        2
  •  0
  •   rhoerbe    10 年前