0

If you've got a function like this inside a class called 'A'

public updateResponse(UpdateRequest updateRequest){
     //...
}

Where UpdateRequest is another class which you create an object from as in UpdateRequest ur = new UpdateRequest();

What is the relation between those two classes (Between 'A' and 'UpdateRequest')? I thought of an "usage" link between the interface of A and the class UpdateRequest. Is this correct? If not, what kind of link should it be?

Gooey
  • 4,740
  • 10
  • 42
  • 76

1 Answers1

0

If the diagram is a class diagram there is no relationship to be taken from your question.

The relationship between these two classes would be best show in a Sequence Diagram or an Activity Diagram. These show method calls etc, a method may be a member of a class in a class digram but it wouldn't really be expressed as a link. Unless you specifically wantto highlight this method, you could then put a usage link to the method on the class. But its not always good practice to do this for every method as you end up with a very messy class diagram.

It's always best to show these relationships in the diagrams you have to show the usage of the method.

EDIT: How does the class A instance relate class UpdateRequest instance?

Q - What relationship are you trying to show? A - Method/function call.

Some class calls updateResponse and the information flow is an UpdateRequest instance.

Therefore... From left to right

SomeClass --|                              A
     |      | a = new UpdateRequest        |
     |<-----|                              |
     |                                     |
     |        updateResponse(a)            |
     |------------------------------------>|

Your sequence diagram might look something like this. There is no specific relationship drawn between class A and UpdateRequest as it is simply a piece of information that flows through the method call you have in your example. If the class was a member of the class, then the relationship would be shown directly on a class diagram, not applicable here. All the classes might (should) shown on a class diagram seperately, this can then be used as a reference point about all the objects in any diagram for those that need to analyse the design.

tigerswithguitars
  • 2,497
  • 1
  • 31
  • 53
  • That's not what I ment here. You create an instance of a class, that is used by another class. What is the relation link between these two classes then? – Gooey Oct 07 '12 at 18:27
  • I have added an edit to help explain how I see your example. But please read around the other topics to make sure you get the principle :) . Good way to learn. – tigerswithguitars Oct 18 '12 at 14:49