Inheritance - Learning Station
Station 1: Design the UMLs
AS A GROUP, design a simple UML diagram (with at least 3 classes) that uses inheritance and association to represent the data below. You may add any additional attributes and behaviours.
What did you find challenging about this station? Why? Add any additional reflections on what you learned in this station.
I found the amount of variables to be challenging in this station. Most variables need an accessor and a mutator, which ends up clogging the UML and makes it harder to read. This also makes the constructors very complicated as they have lots of parameters. It took a lot of time and going over to settle on this version of the UML as I had to make many slight adjustments. I also learned how a “has-a” and “is-a” relationship affect the UML. For example, the a Person “has-a” Date, and in the Person class, the getDOB() method returns Date. This station has shown me that it’s very important to go over and analyze what you wrote in your UML. You can’t just copy and paste previous UMLs as every one has different needs. I needed to take some time and create a specific UML that I thought represented the data the best. This included taking breaks and looking at it with a fresh pair of eyes.
Station 2: Construct the code
AS A GROUP, construct the code for the OVAL and RECTANGLE class based on the UML below.
What strategy did you use to help your construct the code? Add any additional reflections on what you learned in this station.
The strategy that I used to construct the code is similar to all my previous attempts at constructing code, where I work from top down. In the first slide, I knew that the rectangle class extended from the FillableShape class because of the UML. With that information, I was able to create my first line. I then like to do my variables, so I referenced the UML to find what pieces of code I needed. After that, I just went down the UML and worked line by line until I reached the end up the UML. After that, I looked over my work to ensure that no pieces of code were missing. The second slide was similar as I knew it would extend from the FillableShape class as well. I did the variables and worked line by line as well. I find that working top down is very helpful with UMLs as jumping from different sections of code makes it hard to keep track of what’s complete and not. I also learned that it’s important to reference your UML frequently to ensure that you are doing what you’re supposed to. I almost found myself putting the wrong code blocks into different sections as I got carried away and forgot to double check what the UML said.
Station 3: Predict the Code
INDIVIDUALLY, predict the output by matching the given output to the programming statement
AS A GROUP, compare your results with each other and discuss any values that do not match in the tables
What did you learn from this station? Add any additional reflections on what you learned in this station.
I learned from this station the importance of tracing carefully and slowly. The first two slides could be traced pretty quickly as there wasn’t as much to keep track of. I did write down my path on a piece of paper as I wanted to ensure that I didn’t make any strange errors. The third and fourth slide required more concentration than the first two. I had to trace slowly on my paper because I was interacting with much more code. The fourth slide especially was hard as I had to keep jumping to different constructors and print out different variables at different times. I found that writing the values of variables and the output while going through the code helped. As with previous learning stations, my paper helped me substantially with these kinds of stations. I might be able to do the same on a digital notepad, but I find paper to be much quicker and easier for me. I will continue to keep a sheet of paper beside me when I code.
Station 4: I’m a Compiler/JVM
AS A GROUP, review the code and pretend you’re a Compiler.
Identify the error by:
- Identifying the Syntax error
- fixing the error
- adding your OWN custom error message
What are you still unsure about, regarding inheritance? How will you you resolve this? Add any additional reflections.
I’m still unsure about using “super” when working with inheriting. Jumping to different pieces of code seems complicated and is hard to keep track of. I will resolve this by practicing more code that utilizes “super” and using the paper next to me to note down what the “super” is referencing. By going slowly and writing down the connections between classes, I believe that I will become more confident in using “super” in my code. The second slide also reminded me that super could be implicitly called, but sometimes you may need to call it with a parameter. It also reminded me that super has it be the first statement inside a child constructor.