Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
267 views
in Technique[技术] by (71.8m points)

java - How I can represent this relation in class diagram?

I made a Java application where each class performs a processing and at the end it creates an instance of another class. It also calls a method of this class and passes results to it in the parameters of the method like this:

public class Matrix{
     public double CalculerMinimum()
     {
        ....
           if ((result < min)) {
                        min = result;
               }
       

            Liste lis  = new Liste();
            lis.getFile(min);
         return min;
     }
 }
public class Liste{
     public string getFile(double min)
     {
        ....
           
         return lien;
     }
}

What is the relationship between classes? how I can represent that with a class diagram?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your Matrix class creates and uses the Liste class. This is called a dependency. You can represent it in a class-diagram with a dotted arrow and ?use? and/or ?create?.

Your code shows no kind of association nor generalization. The fact that a Liste is used in the implementation of an operation is not sufficient to make an association: this Liste is local and encapsulated in the operation; there is no conceptual association between the two classes themselves (and you could imagine an implementation of CalculerMinimum() that doesn't use any Liste).

What you cannot represent in the class-diagram is the dynamic of the behavior. If you're interested in the dynamics you'd need to use a behavior diagram.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...