The document shows examples of how to implement Java code from UML diagrams, including:
1) Implementing classes like Student and Course from UML class diagrams with attributes, operations, and visibility.
2) Translating associations like between Student and Schedule into Java code with references between classes.
3) Demonstrating generalizations, interfaces, compositions, and other UML constructs in Java code.
Advanced Flow Concepts Every Developer Should Know
Mapeamento uml java
1. Mapeamento de UML -> JAVA
Como implementar Código JAVA a partir de
algumas notações UML.
2. // Notes will be used in the
// rest of the presentation
// to contain Java code for
// the attached UML elements
public class Course
{
Course() { }
protected void finalize()
throws Throwable {
super.finalize();
}
};
Course
Representação de notas
3. public class Student
{
private String name;
public void addSchedule (Schedule theSchedule; Semester forSemester) {
}
public boolean
hasPrerequisites(CourseOffering forCourseOffering) {
}
protected boolean
passed(CourseOffering theCourseOffering) {
}
}
Visibilidade para Atributos e Operações
Student
- name : String
+ addSchedule (theSchedule: Schedule, forSemester: Semester)
+ hasPrerequisites(forCourseOffering: CourseOffering) : int
# passed(theCourseOffering: CourseOffering) : int
4. class Student
{
private static int nextAvailID = 1;
public static int getNextAvaiIID() {
}
}
Escopo de atributos, operações e classes
Student
- nextAvailID : int = 1
+ getNextAvaiIID() : int
7. Schedule
Student
class Student
{
public Student() { }
private Schedule theSchedule;
}
// no need to import if in same package
class Schedule
{
public Schedule() { }
private Student theStudent ;
}
Associações
Bi-direcional
16. GroundVehicle
class Truck extends GroundVehicle
{
public float tonnage;
public void getTax() { }
}
class GroundVehicle
{
public int licenseNumber;
public void register() { }
}
+licenseNumber: int
+register()
Truck
+tonnage: float
+getTax()
Generalização