My favorite part of computer science is algorithm design. In the first six weeks, the class had not been taught enough Java to get into algorithm design very much. But now that we know most of the basics of Java, programming is no longer the problem: algorithm design is. The first lab that really had some algorithmic freedom was the GCD (greatest common divisor) lab. There were so many ways to solve the problem, I decided to have fun and make three of them. My first method was a brute-force method, that is, it checked through all possible solutions until it found the correct one. I was not satisfied with this method, as I felt that there had to be a more elegant, faster solution. It turns out there was a mathematical procedure to find the GCD, called Euclid's Algorithm. This method was guaranteed to find the GCD in many fewer iterations than a brute-force method. Euclid's Algorithm is ripe for recursion, as the results of the algorithm are fed back into the algorithm until certain conditions are met.I greatly enjoyed creating these various methods to solve the same problem, and I hope that such algorithmic variety will be present in future labs.
I have begun to see some of the downsides to objects. While object-oriented programming can make some things easier by hiding complexity, they can sometimes make programs more complex than they need to be. For example, in the Let's Make a Deal lab, I felt that having a "Deal" object made the program more complex, not simpler. All of the local variables required to store various properties of each iteration felt redundant and not very elegant. Part of the problem was that I may not have designed my "Deal" objects in such a way that they did not have to interact directly with the main program. In this lab I was not sure if I could design my own methods and member variables, but if I could, I would try to put as much code into the Deal class as possible. A public static counter in the deal class could even keep track of the number of wins and the percentages. This lab was the only one so far that did not leave me feeling accomplished when I finished it. How strict are the code design decisions imposed by the lab? Is it acceptable for me to redesign classes?