This repository contains my solutions while taking CSC470 Software Engineering (using PlantUML, Java, and MariaDB) from Colorado State University, Global Campus.
Create a business use case diagram for a restaurant. Include several business actors with needs and goals as related to the restaurant and business use cases, expressing expectations of the actors from the business. Your diagram should include both external and internal business views of the restaurant [PlantUML].
Create a use case diagram with flows and alternative flows for an online shopping scenario [PlantUML].
Create a detailed activity diagram that shows partitions, multithreads, and decision points for a scenario of your choosing [PlantUML].
Create an inheritance hierarchy in an example class diagram. Include an abstract class in your inheritance hierarchy. Write sample code to explain this inheritance in design [PlantUML].
Create a sequence diagram of a hospital management system. Include the following notations: actor, object, timeline, focus of control, message, self-message, return message, asynchronous message, object destruction, steps (in a sequence), and notes [PlantUML].
Provide sample code with your sequence diagram activity.
Create a database model according to the following steps:
-
Create a simple class diagram containing three classes: Vehicle, Car, and Truck [PlantUML].
-
Create a rough sketch of a relational table that will store the objects belonging to the aforementioned three classes.
-
Enter two objects per table, corresponding to the classes.
-
-
Create a simple association relationship in a separate class diagram showing Driver and Car [PlantUML].
-
Add/modify your table designs to handle storing of two objects belonging to Car and two belonging to Driver [PlantUML].
- Modify the multiplicity on the Driver side to N. This makes it a many-to-many multiplicity.
-
Modify your table designs to handle this multiplicity and show where and how the KEYS or IDs will have to be placed.
-
Create a class diagram corresponding to the tables you have designed.
Part 1 was completed as a draft in the Module 7 Portfolio Milestone. Please make any updates necessary to that Milestone, being sure to incorporate instructor feedback.
Using a programming language of your choice, write a script that will print out code of your model [PlantUML].
plantuml_to_java.sh
#!/bin/bash
# Make executable: chmod +x plantuml_to_java.sh
# Usage: ./plantuml_to_java.sh <input_file> <output_dir>
# Test: ./plantuml_to_java.sh vehicle_management.puml src
# Check if the correct number of arguments are provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <input_file> <output_dir>"
exit 1
fi
# Function to convert PlantUML to Java
convert_plantuml_to_java() {
local input_file="$1"
local output_dir="$2"
local class_name=""
local in_class=false
local is_abstract=false
# Read the input file line by line
while IFS= read -r line
do
# Remove leading and trailing whitespace
line=$(echo "$line" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
# Check if the line defines a class
if echo "$line" | grep -qE '^(abstract[[:space:]]+)?class[[:space:]]+[A-Za-z0-9_]+([[:space:]]*\{?)?$'; then
# Extract the class name
class_name=$(echo "$line" | sed -E 's/^(abstract[[:space:]]+)?class[[:space:]]+([A-Za-z0-9_]+).*/\2/')
in_class=true
is_abstract=false
# Check if the class is abstract
if echo "$line" | grep -q "abstract"; then
is_abstract=true
fi
# Create the Java file and write the class declaration
if $is_abstract; then
echo "public abstract class $class_name {" > "$output_dir/$class_name.java"
else
echo "public class $class_name {" > "$output_dir/$class_name.java"
fi
elif $in_class; then
# Check if the line defines an attribute
if echo "$line" | grep -qE '^[+-][[:space:]]*[A-Za-z0-9_]+[[:space:]]*:[[:space:]]*[A-Za-z0-9_<>]+'; then
# Extract visibility, name, and type of the attribute
visibility=$(echo "$line" | cut -c1)
name=$(echo "$line" | sed -E 's/^[+-][[:space:]]*([A-Za-z0-9_]+).*/\1/')
type=$(echo "$line" | sed -E 's/.*:[[:space:]]*([A-Za-z0-9_<>]+).*/\1/')
# Write the attribute declaration
if [ "$visibility" = "+" ]; then
echo " public $type $name;" >> "$output_dir/$class_name.java"
else
echo " private $type $name;" >> "$output_dir/$class_name.java"
fi
# Check if the line defines a method
# Check if the line defines a method or constructor
elif echo "$line" | grep -qE '^[+-][[:space:]]*[A-Za-z0-9_]+\([^)]*\)([[:space:]]*:[[:space:]]*[A-Za-z0-9_<>]*)?'; then
# Extract visibility, name, parameters, and return type of the method
visibility=$(echo "$line" | cut -c1)
name=$(echo "$line" | sed -E 's/^[+-][[:space:]]*([A-Za-z0-9_]+).*/\1/')
params=$(echo "$line" | sed -E 's/^[^(]+(\([^)]*\)).*/\1/')
return_type=$(echo "$line" | sed -E 's/.*:[[:space:]]*([A-Za-z0-9_<>]+).*/\1/')
# Remove types from all method parameters
params=$(echo "$params" | sed -E 's/[A-Za-z0-9_<>]+[[:space:]]+([A-Za-z0-9_]+)/\1/g')
# Check if it's a constructor
if [ "$name" = "$class_name" ]; then
# Write the constructor declaration
if [ "$visibility" = "+" ]; then
echo " public $name$params {" >> "$output_dir/$class_name.java"
echo " // TODO: Implement constructor" >> "$output_dir/$class_name.java"
echo " }" >> "$output_dir/$class_name.java"
else
echo " private $name$params {" >> "$output_dir/$class_name.java"
echo " // TODO: Implement constructor" >> "$output_dir/$class_name.java"
echo " }" >> "$output_dir/$class_name.java"
fi
else
# Set default return type to void if not specified
if [ -z "$return_type" ]; then
return_type="void"
fi
# Write the method declaration
if [ "$visibility" = "+" ]; then
if $is_abstract; then
echo " public abstract $return_type $name$params;" >> "$output_dir/$class_name.java"
else
echo " public $return_type $name$params {" >> "$output_dir/$class_name.java"
echo " // TODO: Implement method" >> "$output_dir/$class_name.java"
echo " }" >> "$output_dir/$class_name.java"
fi
else
echo " private $return_type $name$params {" >> "$output_dir/$class_name.java"
echo " // TODO: Implement method" >> "$output_dir/$class_name.java"
echo " }" >> "$output_dir/$class_name.java"
fi
fi
# Check if the line closes the class
elif [ "$line" = "}" ]; then
echo "}" >> "$output_dir/$class_name.java"
in_class=false
fi
fi
done < "$input_file"
# Close the class if it's still open
if $in_class; then
echo "}" >> "$output_dir/$class_name.java"
fi
}
# Main script
input_file="$1"
output_dir="$2"
# Check if the input file exists
if [ ! -f "$input_file" ]; then
echo "Error: Input file does not exist."
exit 1
fi
# Create the output directory if it doesn't exist
if [ ! -d "$output_dir" ]; then
mkdir -p "$output_dir"
fi
# Convert PlantUML to Java
convert_plantuml_to_java "$input_file" "$output_dir"
echo "Conversion complete. Java files have been created in $output_dir"Driver.java
public class Driver {
private int id;
private String name;
private List<Vehicle> vehicles;
public Driver(id: int, name: String) {
// TODO: Implement constructor
}
public int getId() {
// TODO: Implement method
}
public String getName() {
// TODO: Implement method
}
public void addVehicle(vehicle: Vehicle) {
// TODO: Implement method
}
public List<Vehicle> getVehicles() {
// TODO: Implement method
}
}Vehicle.java
public abstract class Vehicle {
private String make;
private String model;
private int year;
public Vehicle(make: String, model: String, year: int) {
// TODO: Implement constructor
}
public abstract String getMake();
public abstract String getModel();
public abstract int getYear();
}Car.java
public class Car {
public Car(make: String, model: String, year: int) {
// TODO: Implement constructor
}
}Truck.java
public class Truck {
private double cargoCapacity;
public Truck(make: String, model: String, year: int, cargoCapacity: double) {
// TODO: Implement constructor
}
public double getCargoCapacity() {
// TODO: Implement method
}
public void setCargoCapacity(cargoCapacity: double) {
// TODO: Implement method
}
}Discuss two key differences between class diagrams in analysis and those in design. Use applicable examples (diagrams or pseudocode) in your post.
Class,
I started working on the Portfolio project and I will answer the discussion question using diagrams I created from the project sources. These are not the relational database diagrams asked for in the actual portfolio project, but they really display the difference between design and analysis class diagrams.
I created a database, vehicle_management, on a MariaDB server I am running on my local machine. I created Java classes for Vehicle, Truck, Car, and Driver. I associated drivers with cars (but not trucks) and added them to the database. I created another Java class that displays tables for the cars and drivers. This is a use-case diagram for the package I created [PlantUML]:
And here is a class diagram for analysis [PlantUML]:
You can see the diagram is vague and abstract. It doesn’t include attributes or methods (though it can if they are needed for added detail). It would be difficult to start writing code from such a diagram, but it is simpler and easy for someone that is not a developer to understand.
The design class diagram is much more specific, and includes actional items such as attributes and methods, as well as what is public, private, static (underlined), or object oriented. It also shows how the package connects to the database [PlantUML].
You can see the analysis class diagram focuses much more on the "what" rather than the "how," and the design diagram focuses more on the “how” than the “what.”
I’ve attached the PlantUML source code for these diagrams as well as the SQL query I used to create the database and populate it with some dummy values if anyone wants them. The SQL query should be compatible with MySQL but may require minor changes. If anything turns red it should be pretty easy to fix. You have to be logged in as a user with all privileges to create the vehiclemanager user, then you can log into the database using user: vehiclemanager password: CSUGlobal.
-Have Fun!
-Stephan Peters
What are the strengths and limitations of sequence diagrams? Provide specific scenarios in your post.
Class,
Some strengths of sequence diagrams are clear Visualization of interactions, temporal flow, e.g. they clearly depict the order of method calls and messages over time, making it easy to understand the flow of operations. They also show when objects are created and destroyed during the execution of a scenario, and they can represent parallel processes and the timing of interactions between them. Using a sequence diagram, different types of messages (synchronous, asynchronous, return) can be easily distinguished.
Some weaknesses of sequence diagrams are a limited representation of complex logic: as mentioned in the diagram shown below, sequence diagrams struggle to represent complex internal logic or conditional flows within methods or classes. They're not ideal for showing complex data structures or relationships between classes. Loops are awkward and difficult to represent. Sequence diagrams represent a single scenario or use case and may not effectively show all possible execution paths in complex systems. They are also not very scalable. For large systems with many interactions, sequence diagrams can become overly complex and difficult to read. While they show interactions, they don't inherently represent the changing states of objects (Ricciardi, 2025; Unhelkar, 2020).
The diagram below shows the User interacting with the VehicleFactory to create different types of vehicles, the VehicleFactory creating instances of SUV, Sedan, and PickupTruck, and the flow of messages between objects, including object creation and return values [PlantUML].
This sequence diagram is good at showing the order of operations and interactions between different parts of the system. However, it doesn't capture the internal complexity of each component, such as the logic inside the VehicleFactory or the inheritance hierarchy of the vehicle classes.
-Have Fun!
-Stephan Peters
References:
Ricciardi, A. (2025, January 24). A guide to UML sequence diagrams: Notation, strengths, and limitations. Omegapy. https://www.alexomegapy.com/post/a-guide-to-uml-sequence-diagrams-notation-strengths-and-limitations This resource gives a summary of the strengths and weaknesses as outlined in Unhelkar, 2020.
Unhelkar, B. (2020). Software engineering with UML (pp. 209–211). CRC Press.
Feb 19 2:06pm Reply from Angelo Luo
... What are some other techniques or tools that you think can be used in conjunction with sequence diagrams to address their limitations, such as representing complex logic or handling large-scale systems?
Professor Luo,
Using additional diagrams to represent complex logic or handling large scale systems referenced from the main sequence diagram will make an overview diagram much more usable.
I might even suggest using Markdown to keep all these diagrams, including parent and child diagrams up to date in an easy VCS friendly format, so they can be easily referenced. I use Typora to generate markdown documents, and it includes support for several UML to diagram services using Mermaid. A main markdown document can be included with the project and updated as the project evolves using simple text-based Mermaid compatible UML scripts. Unfortunately, Mermaid (and therefore Typora) does sot support PlantUML. Also, the Linux version of Typora does not support SVG which may be necessary to zoom into complex diagrams. Typora also requires a per-device paid license. It's a low-dollar license ($14.99 perpetual for up to three revolving devices) but there is still a cost.
A disadvantage of doing it this way is not all markdown viewers will support the diagramming UML. It doesn't look like ReText or GhostWriter natively support this use (and they have limited Windows support). It might be necessary to regenerate all the updated diagrams into an image format before pushing the update, but that's a great job for a simple shell script at push time, that is after updating and committing the markdown generate the diagrams - re-commit with the updated image files - push.
Now that I'm done with my off-topic suggestion on how I think it would work well, much better than Visio or Draw.io I'll give an example support document based on the Vehicle Creation Sequence diagram that displays a parallel process. @Caleb has me thinking about diagramming parallel processes. Obvious examples from our course that might display parallel processing well are an activity diagram or a state machine diagram. I am using an Interaction Overview diagram that is kind of like a hybrid between activity and sequence diagrams [PlantUML].
You can see how this diagram includes references to the original sequence diagram from my initial post, and it might be included in the same markdown file with the sequence diagram.
Another possibility for more complex systems might be Business Process Model and Notation (BPMN) diagrams, usually produced using Visio (which is unfortunate). They can be generated and edited using XML using various tools which is how I would do it.
-Have Fun!
-Stephan
References:
Object Management Group. (2023). BPMN specification - business process model and notation. bpmn.org. https://www.bpmn.org/
typora.io. (2022, September 5). Draw diagrams with markdown. Typora.io. https://support.typora.io/Draw-Diagrams-With-Markdown/
Compare a state machine diagram with a sequence diagram and discuss the differences between the two.
Class,
Below are a state machine and sequence diagram for a car rental or fleet management business, generated from the package I’d created while doing the Portfolio Project.
The state machine diagram helps to understand the different states a vehicle can be in in this system, e.g. Available, Reserved, Rented, or Under Maintenance and how the vehicle transitions between these states (Sparx Systems, 2025)[PlantUML].
The sequence diagram shows how the process of searching for a car, making a reservation, renting, and returning a car works, including which components are involved and how they communicate (Bell, 2004)[PlantUML].
The state machine diagram focuses on the different states a vehicle can be in and the transitions between these states. It shows the lifecycle of a vehicle in the system, while the sequence diagram: This diagram illustrates the interactions between different objects or components in the system over time. It shows how processes operate with one another and in what order.
The sequence diagram has a timeline of the interactions between different parts of the system from top to bottom, while the state machine diagram has no explicit representation of time. It shows possible state transitions but doesn't indicate when they occur.
The state machine diagram is more abstract, focusing on the high-level states of a vehicle without detailing the processes that cause state changes, where the sequence diagram is more detailed, showing specific method calls, their order, and the flow of information between different components of the system.
The state machine diagram focuses on a single entity (a vehicle) and its possible states, and the sequence diagram shows multiple components of the system and how they interact.
The state machine diagram is simpler and easier to read at a glance, providing a quick overview of the system's states, where the sequence diagram is more complex for larger processes, though it does provide a clear step-by-step view of how a process unfolds.
- Have Fun!
- Stephan Peters.
References:
Bell, D. (2004, February 16). Explore the UML sequence diagram. IBM Developer. https://developer.ibm.com/articles/the-sequence-diagram/
Sparx Systems. (2024). State machine diagram - UML 2 tutorial. Sparxsystems.com. https://sparxsystems.com/resources/tutorials/uml2/state-diagram.html
Unhelkar, B. (2020). Software engineering with UML. CRC Press.
Mar 7 4:44pm Reply from Angelo Luo
... Another area to consider is how sequence diagrams can be used to optimize system performance by identifying bottlenecks or inefficiencies in the communication flow. How do you believe these diagrams can be effectively used in conjunction with other modeling techniques, such as use case diagrams, to provide a comprehensive view of the car rental system?
Professor Luo,
Adding additional diagrams, such as the use-case diagram below can give a clear picture of additional actors who interact with the system and clearly show how the primary use cases interact with the diagrams I provided in the original post with use cases corresponding to systems shown in those diagrams. This use-case diagram also shows user interaction and potential system automation. While the state machine diagram focused on the states of a vehicle, this use case diagram gives a broader view of the entire rental process, including actions that don't directly change the vehicle's state (like checking availability) and implies certain business rules. For instance, the fact that customers can cancel reservations suggests there's a cancellation policy in place [PlantUML].
The use-case diagram adds context that wasn't present in the other diagrams. For example, the "Manage Inventory" use case suggests backend operations that aren't directly reflected in the vehicle states but are crucial for system operation. And this can be important with things like the modified sequence diagram below with an added note identifying a bottleneck and some other potential issues [PlantUML]:
This modified diagram serves as a tool for communicating potential issues with stakeholders, as it provides a clear, high-level view of system functionality and potential issues that are easy for non-technical individuals to understand. A stakeholder will want to purchase as few vehicles as possible, when presented with the possibility insufficient inventory may cause the venture to fail the stakeholders have the option of properly funding the inventory or not pursuing the project. It also displays other potential issues.
I hope this answers your questions.
-Have Fun!
-Stephan
