Week 12 Class 22 Thu Apr 03 Posted: Apr 03
Announcements
Square Brackets
Some of you are having issues with showing multiplicity in your yuml class diagrams. I showed multiple examples of this in class, but forgot how I got it originally working. First take a look at this diagram and the corresponding yuml input and note the square brackets for multiplicity:
The square brackets around the entire class are not the same as the multiplicity brackets, as the multiplicity brackets:
[
' bracket and to the right of the ']
' bracket. That is not a space next to them. It is part of the character.These are called fullwidth square brackets. That is where I originally got them from.
So how do you use them? You can copy them from the examples above and paste them in. The hex unicode for regular brackets are U+005B
and U+005D
, and for the fullwidth brackets U+FF3B
and U+FF3D
.
Exercise 55: Names
Score in Brightspace. Feedback in Report.md in the repo.
There is a strong possibility that this will be in a question on the Final Exam.
Exercise 62: Static Dispatch
Feedback is in the file oracle.txt in the branch feedback in your repository. The oracle.txt is the difference between the oracle (with the correct answers) and your Base.cpp. If the oracle.txt is empty, then that means your answer is correct (reflected in your score). Even if your answer is correct the oracle.txt may show some differences. The differences were manually examined and I used more direct techniques to determine if there were any dynamic dispatch in your answer.
There is a strong possibility that this will be in a question on the Final Exam.
Agenda
Exercise 63: Names II
Using the feedback in the Report.md, fix your Names code.
If you have no changes to make (based on the feedback), leave the code alone.
Exercise 66: Dynamic Dispatch
The repository Base has a set of various method call situations, and a way at run time (using assert()
) to verify which method is actually called.
assert()
in the code that indicates (via a string) which method is called, e.g., for m2()
is it "Base::m2()"
, "Derived::m2()"
, or "DerivedDerived::m2()"
?assert()
, e.g.,Handle each assertion one at a time in order, compiling and running the program (i.e., make run
) after each assertion is completed. The assertion you edited should pass, and you should be onto the next assertion.
You are required to commit for each block of statements in the main program.
Exercise 67: VTable Diagram
There is no standard diagram to show a vtable. These are my own created using dot notation with GraphViz. GraphViz is for general graph visualization. You can create UML diagrams in GraphViz, but you have to much more work yourself, unlike yuml. Many of the more complex UML Class Diagrams in the notes, especially for design patterns, use GraphViz as it provides more control over the arrangements of the nodes (classes). The vtable diagrams in the notes were originally done as modified UML Class Diagrams in yuml, e.g., VTable Base Pointer but I converted them to GraphViz.
In this exercise, you will complete a VTable diagram with a new class, Rectangle
, which inherits from the class Shape
.
The diagram already has all classes and all method definitions. You just have to complete the vtable so that the method pointers in the vtable point to the correct function.
The easiest way to work with the diagram is with GraphVizOnline. Start with the base diagram, and add the dot notation for the vtable method pointers to the correct methods. You can use the Shape and Circle VTable Diagram for an idea of how to get the edges from the Rectangle vtable to the functions.
To get credit, all edges must be correct.
You can also convert the VTableRectangle.dot file using the command-line tool, dot
The dot
program is available on macOS and WSL/Linux with the package graphviz. I also added it to the GitHub Codespaces image.
Note that dot
is part of a number of graph-drawing algorithms (see man dot
). This one uses fdp
to control the placement of the nodes.
Unless otherwise noted, exercises are due by 4:30 pm on Monday, Apr 7.