Designing the Control Layer

In week five we began designing the control layer of our game. The control layer comprises the classes that are ultimately responsible for the behavior of the program. I see the control layer as being sandwiched between the model layer we designed last week and the view layer we will be developing later. It communicates between the two layers but does not directly control any input or output that the user will see.

Before starting we read a chapter called “Designing the Control Layer,” and watched a couple of videos about designing test matrices. Then we met as a team to work on of the control layer classes together. First, we created all the classes in the control layer and determined the necessary functions that each would have. Then we attached them with dependency associations to the appropriate model layer classes. After that, we chose a complex function and worked on it as a team, designing our own test matrix to ensure our function performed as expected.

This week I felt like I understand the purposes for the different layers in a Java program and how they fit together. I also appreciated learning about creating test matrices. I’d heard about test cases before, but I’d never really understood how they were used, and walking through a matrix and writing my own function in pseudo code was very helpful.

The individual assignment was especially challenging for me this week. I was tasked with creating a function that calculated the proper dosage of medication our player would need based on their weight. That alone would not have been difficult, but it also had to output an amount in multiples of 250. I wanted to take the easy route on this and simply add pseudo-code that stated to round the amount to the nearest multiple of 250, but I realized that I needed to really understand how this function was going to work, so I kept working at it.

I struggled for quite some time determining how evaluate my initial dosage and round it up or down appropriately, and I initially thought I’d be using an “if” statement. However, after some research on Oracle’s Java documentation and StackOverflow, I realized a “switch” statement would be a cleaner method. I’m sure there are other ways of accomplishing this task. This turned out to be the most interesting part of this week’s work for me. It was a real brain teaser, but it felt good to come up with a solution.

New UML diagram with Control Layer added.
New UML diagram with Control Layer added.