为什么两个类在ClassDiagram中没有连接? [英] Why two class is not connected in ClassDiagram?

查看:42
本文介绍了为什么两个类在ClassDiagram中没有连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当然,我在 project_Utils 类中使用了 UserMemoryParse 类的方法.但是,两个类之间的任何关系都没有在类图中定义.

代码

这是我与上述情况相关的代码

很明显,两个类都有关系.....但是,为什么在类图中找不到任何关系线?

(+ +有些线很细,而有些线很粗(两者都是关联关系),两者之间有什么区别)

 `[1.Project_Utils类]私有void parseData(){mSequencEvent.onUtilUpdateStatus(IOnSequence.STATUS.PARSE);mapParseData.clear();列出userList = new ArrayList(mapUserData.keySet());for(int i = 0; i< 5; i ++){字符串userData = userList.get(i).toString();字符串a = mapUserData.get(userData);字符串parseData = UserMemoryParse.pasingData(a,userData);如果(mSequencEvent!= null)mSequencEvent.onUtilUReceivedParseData(parseData);}}[2.UserMemoryParse类]公共静态字符串pasingData(String a,String userMemory){字符串parseData =错误";尝试 {//十六进制到二进制字符串binaryUserData = new BigInteger(userMemory,16).toString(2);} 

`

解决方案

使用另一个类的操作是一种行为功能,而不是静态功能.通常,UML类(图)生成器仅查看类的静态部分(在大多数语言中,头文件中的静态部分),并且它们不解析实际代码.如果存在任何此类情况,则需要在两个类之间手动添加依赖项.使用工具并不意味着它是a)正确的(使用共享聚合首先很奇怪,而对自身而言它看起来很荒谬)或b)会创造出您可能会喜欢的东西.无论如何,您都需要人工返工.在这里:手动绘制依赖关系.

Overall Class Diagram I drew class diagram in android Studio. First picture is my class diagram. I have a question about it.

this is the problem

Definitely, I used method of UserMemoryParse class in project_Utils class. But any relationship between two classes is not defined in class diagram.

Code

This is my code related with aforementioned situation

Obviously two class have relationship ..... But why any relationship line can not be found in class diagram?

(+ and some line is thin while some line is thick (both of are association of relationship) what is the differences between that)

`        


[1.Project_Utils class]
    private void parseData()
    {
        mSequencEvent.onUtilUpdateStatus(IOnSequence.STATUS.PARSE);
        mapParseData.clear();
        List userList = new ArrayList(mapUserData.keySet());

        for(int i=0; i<5; i++) {
           String userData = userList.get(i).toString();
           String a = mapUserData.get(userData);
               String parseData = UserMemoryParse.pasingData(a,userData);
               if (mSequencEvent != null)
                   mSequencEvent.onUtilUReceivedParseData(parseData);

        }
    }



[2.UserMemoryParse Class]

 public static String pasingData(String a, String userMemory) {
        String parseData = "Error";
        try {
            //HEX to binary
            String binaryUserData = new BigInteger(userMemory, 16).toString(2);

}

`

解决方案

Using an operation from another class is a behavioral feature, not a static one. UML class (diagram) generators in general only look at the static part of classes (which is in most languages what uses to be in header files) and they do not parse the actual code. If any such condition is present you would need to manually add a dependency between both classes. Using a tool does not mean it is a) correct (using shared aggregation is strange in first place and on self it looks just absurd) or b) will create something you may find pleasing. In any case you need a manual re-work. Here: draw the dependency manually.

这篇关于为什么两个类在ClassDiagram中没有连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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