SDM: Lab 2: UML with LucidChart and SequenceDiagram.org
SDM Lab 2: UML with LucidChart and SequenceDiagram.org
Today's first tool is LucidChart. I have chosen this one because its free account will be more than adequate for your needs in the course, it is pretty easy to use and seems reliable. It is more a drawing tool than an IDE, however, and it has a few issues that irritate me. For example, it insists on drawing UML classes etc. using rounded-edged rectangles when they really should be sharp-cornered rectangles. The documentation is pretty good but another small caveat is that I considered recommending the LucidChart ten-minute UML class diagram tutorial to you, but decided not to at the second technical error in it.
Play around and use the documentation and tutorials as necessary to use LucidChart. To get you started: use shapes from the UML Class
Diagram section (if you don't see them in your left panel, click Shapes to get a list of shape types where you can tick UML, and go from there); drag them onto the canvas; for relationships, use the attachments to the classes, and simply get the right kinds of line and
arrowheads using the drop down menu in the toolbar; to edit text, double-click it first. One thing to note: classes with and without attribute/operation sections are different shapes in LucidChart, so think about which you want to use before you pick each one: it's a pain to change later. You will also need the Standard shapes, which include a text box, which you can use to give association names or role names.
We're going to work with the Paleo example: you may like to have the draft UML class diagram we came up with last week in front of you.
Conceptual class diagram
Reproduce the class diagram we created in class from the Paleo example. If you have ideas about how it could be improved, also create an improved version.
Lay out the diagram so that it is clearly readable (e.g., make sure your multiplicity specifications haven't got hidden by anything).
Using the File menu, export your diagram as PNG.
Look at Piazza for a post entitled Lab 2 class diagram. If there isn't one, you're the first: make a post with that title, including your PNG file. If there is one, read the post and any comments and compare your diagram with what has been posted. Consider posting yours for comparison.
Java
In your favourite Java IDE (Eclipse, IntelliJ, or even an editor like emacs will do) create a new Java project paleoJava, and (manually: we'll come back to code generation later in the course!) create Java classes corresponding to the class diagram you have just developed.
Next, suppose our conceptual class diagram is going to be used to support the development of a system in which the user, who is thinking of a food, will be asked questions in the appropriate sequence and finally told whether their food accords to the diet or not. For example, given the original paleo diagram, if the user is thinking of a fish, they will first be asked "Did it have a face?", they will answer Yes, and the system will tell them "It's paleo".
Add operations to the conceptual class diagram (as simply as possible: don't concern yourself with the user interface, just with the logic) to support this.
Add corresponding methods to your Java classes.
Sequence diagram
For this part you will use a different tool, https://sequencediagram.org/
This has a textual syntax for sequence diagrams alongside the UML diagrammatic syntax. It's quite flexible and usable but you may need to look at the Help page to see how to use it - for example, it took me a while to see how to have participants in a sequence diagram such as "q:Question". (This specific issue's solution now seems to be so well hidden as perhaps to be absent! The answer is that you need a line like:
participant "q:Question" as q
i.e. the quoted argument contains literally what you want to see in the lifeline, and the unquoted one specifies a name by which you'll refer to this participant in the text.)
Develop a sequence diagram to show the scenario mentioned above, where the user is thinking of a fish. Go on to think about more extended scenarios. Update your Java code to be consistent with the behaviour you show.
Optional: try doing the same thing (a) in LucidChart (b) in https://www.websequencediagrams.com/
Which do you prefer, and why?
Activity diagram
Create an Activity Diagram, in LucidChart. Use shapes from the UML State/Activity diagram section. We're going to represent the business process of designing a new diet to be this year's craze.
To start with, model a simple process. Create an initial node. (Note that initial notes, final nodes, fork and join bars etc. are all technically pseudostates.) Then, using Activitys (e.g. not States), show consult marketing, write book, write app, profit, and finally, a final node. Join these up in sequence using control flow edges. Check that you know how those should look.
Next, add some parallelism and some choice. Someone points out that the book and the app can both be written at the same time, and suggests that under certain circumstances it might be good to consult a nutrition expert as well as marketing. Revise your model to show appropriate parallelism and choice going on. Check that you understand the conceptual differences between decision (called Branch in LucidChart), merge, fork and join nodes: although in LucidChart the pairs that are visually identical are represented the same way, in a more semantically-oriented UML tool you might have to e.g. pick different elements for a Fork node and for a Join node.