Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
265 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...