D.1.3
Construct unified modeling language (UML) diagrams to represent object designs.
JSR: This would be better stated:
Construct unified modeling language (UML) diagrams to represent template class designs.
Teaching Note:
LINK Connecting computational thinking and program design.
Sample Question:
JSR Notes:
UML stands for Universal Modeling Language, which is a unified, internationally agreed upon way of doing modeling of a wide variety things, including several software tasks such as flow charts, and this, class diagrams.
Below the diagrams is the actual code that would be represented by this example.
The class name goes at the top
Then there is a section for data attributes
Then there is a section for all the methods
- indicates private (for attributes, mainly)
+ indicates public (for methods, mainly)
parameters are given both a name and a type, which follows a colon :
return values are only indicated by type only, which follows a colon :
arrays are given the type and [0..*] (NOTE: I don't have examples for arrays in the diagram above.)
for example, as a parameter + setCourses(courses: String[0..*])
and as a return value + getCourse: String[0..*]
7 8 public class Student { 9 10 //Attributes 11 private String name = "not set yet"; 12 private int grade = -999; 13 14 15 //Constructors 16 public Student(){ 17 } 18 19 public Student(String name, int grade){ 20 this.name = name; 21 this.grade = grade; 22 } 23 24 25 //Accessor Methods 26 public String getName(){ 27 return name; 28 } 29 30 public int getGrade(){ 31 return grade; 32 } 33 34 35 //Modifier Methods 36 public void setName(String name){ 37 this.name = name; 38 } 39 40 public void setGrade(int grade){ 41 this.grade = grade; 42 } 43 44 45 //Other Methods 46 public void printOutStudentInfo(){ 47 System.out.println("The student's name is " + name + 48 ", and they are in grade " + grade + "."); 49 } 50 } 51
Here is another UML Class Diagram "template class" example, this time, with three attributes:
This might be jumping forward quite a bit, depending on when you do D.1.3, but here are a couple of full class diagrams, including all the kinds of relationships you are responsible for knowing about in the OOP option.
Though "standard", you'll see a bit of variation in UML diagrams. It can be argued that since UML is primarily for you the programmer, to help keep yourself organized, that's OK. But since you will be working with others, the more standard you can keep your UML, the better.
You'll note in particular that the way UML class diagrams are constructed in IB documentation varies significantly, as seen in the marking schemes from year to year. Below is a pretty typical "IB style" UML class diagram. Where such IB sourced UML appears in my website, I'll label them "IB style". And you should be comfortable with this style, but do recognize it is not at all standard UML.
Please, when you do your own UML diagrams, even for IB exams, stick with the standard approach used by most programmers, as shown above, at the top of this page.