Universal Modeling Language?

Status
Not open for further replies.

Bagheera

Ars Tribunus Angusticlavius
8,773
Subscriptor
I have a class project which requires me to make UML class, use case, and sequence diagrams. Can anyone here answer questions about UML?

Specifically, I'm not sure if my sequence diagrams are correct. If I posted links to three Java classes and a UML sequence diagram, could someone determine if the diagram was created correctly?
 

Bagheera

Ars Tribunus Angusticlavius
8,773
Subscriptor
I have to make class, use case, and sequence diagrams. The first two are easy, but I'm having trouble grasping the last one.

Project: A table in a SQL database has students records. A Java GUI should display the contents of the table. It should allow users to 1) refresh (requery) the data, 2) add a new record, 3) delete a record, and 4) update a record. I have to make sequence diagrams for each of those four actions.

Here's a description of how adding works: The class MainFrame.java has a JButton named "addButt." addButt has a listener that instantiates AddFrame.java. AddFrame has three JButtons for Undergraduate, Graduate, and PartTime (three sub-classes of Student.java). The three buttons listeners simply make certain JTextAreas visible. AddFrame also has a JButton "submitButt". submitButt's listener instantiates a new UnderGraduate, Graduate, or PartTime object and calls its add() method. It passes the contents of the JTextAreas to add(). The add() method executes a SQL query that inserts the parameters into the table.

Edit: The diagram (a pdf file) is in the link below. Does the sequence diagram correspond to the description above?

Here's a link to some of the class files in question.
 
My first question is, what are you intending the vertical lifelines to represent. They seem to be class names? When we use Sequence Diagrams here, we typically use them to represent processes or threads. But we aren't a strict UML shop, so take that for what it is worth.

The way your third lifeline is set up doesn't seem to make any sense. It has no name and the classes shouldn't be on the lifeline like that. The fourth lifeline should actually have a lifeline. Also, there are no returns here. Everything that moves right, should return to something on the left at the completion of the method call /invocation. Does your frame close? Then it should return. Sometimes this can be simplified with an 'implicit return' that eliminates the return, but that should only be used for simplification.

Take a look through IBM's documentation here:
http://www.ibm.com/developerworks/ratio ... /3101.html

Your diagram should look similar to the ones in their examples.
 

Bagheera

Ars Tribunus Angusticlavius
8,773
Subscriptor
[url=http:/civis/viewtopic.php?p=24907809#p24907809:s15dl89j said:
Trombone8vb[/url]":s15dl89j]My first question is, what are you intending the vertical lifelines to represent. They seem to be class names? When we use Sequence Diagrams here, we typically use them to represent processes or threads. But we aren't a strict UML shop, so take that for what it is worth.

Yes, they're supposed to represent the classes and or object instantiated from those classes. The far-left vertical bar is the lifeline for the MainFrame object (note that the main method is simply "new Mainframe();". There isn't a named object of the MainFrame class. The next object is the AddFrame class (which is also instantiated with simply "new AddFrame();" no object is actually given a name).


I see I could clarify that by listing the method names in the arrows between the lifelines.

The way your third lifeline is set up doesn't seem to make any sense. It has no name and the classes shouldn't be on the lifeline like that. The fourth lifeline should actually have a lifeline. Also, there are no returns here. Everything that moves right, should return to something on the left at the completion of the method call /invocation. Does your frame close? Then it should return. Sometimes this can be simplified with an 'implicit return' that eliminates the return, but that should only be used for simplification.

Take a look through IBM's documentation here:
http://www.ibm.com/developerworks/ratio ... /3101.html

Your diagram should look similar to the ones in their examples.

The "add()" method of each object doesnt' actually return anything, though I realize now it should at least return "true" or "false" to indicate success or failure updating the db. Ditto for the AddFrame object. I'll add those to the diagram and the code.
 
[url=http:/civis/viewtopic.php?p=24908055#p24908055:239cvi4w said:
Bagheera[/url]":239cvi4w]

The "add()" method of each object doesnt' actually return anything, though I realize now it should at least return "true" or "false" to indicate success or failure updating the db. Ditto for the AddFrame object. I'll add those to the diagram and the code.

One of the important things that the Sequence Diagram helps to understand is flow of control. So even if no value is returned you typically want to include a return arrow to indicate control flow.
 

ShuggyCoUk

Ars Legatus Legionis
10,388
Subscriptor++
[url=http:/civis/viewtopic.php?p=24914065#p24914065:94a2x44e said:
blargh[/url]":94a2x44e]
[url=http:/civis/viewtopic.php?p=24901607#p24901607:94a2x44e said:
Bagheera[/url]":94a2x44e] The class MainFrame.java has a JButton named "addButt."

AddFrame also has a JButton "submitButt".
*snicker*

You'll love this then :)
 
Status
Not open for further replies.