Saturday, March 22, 2014
5th Six Weeks
This six weeks we began our first investigation of programming algorithms as opposed to language structure and Java idioms. Searching and sorting are very important concepts in any programming environment, and I enjoyed learning how they worked. I particularly enjoyed implementing the quick sort algorithm from a description on Wikipedia and seeing it compete favorably with Java's Arrays.sort() method. However, copying pseudocode into Java does not engender learning, and I am still somewhat shaky as to the exact implementation specifics of the quick sort algorithm. While Wikipedia does a good job of giving an overview of how an algorithm works, it does a poor job of explaining exactly how each part of an algorithm functions, and how an algorithm might be modified. While this lack of detail was not a major problem for the relatively simple quick sort algorithm, it did prevent Ben and I from implementing the much more convoluted merge sort algorithm. I went over the general description of this algorithm in many different sources, but none of them gave enough detail for me to figure out an implementation for myself. In addition, while I had been able to copy and translate almost line for line the quick sort pseudocode, the heap sort pseudocode was far beyond me. The only way I could possibly understand how to implement merge sort was to find Java code and spend time reasoning through it. The problem is that pseudocode is just too brief to be a complete description of an algorithm. I think that a better method would be to include with the pseudocode a line by line description of exactly what that line does, and how it connects to the rest of the program. Through such an explanation, I could get a much more complete understanding of algorithms. This is similar to what Mr. Stephens provides in class when he describes algorithms. However, it would be useful for it to be written down for convoluted algorithms such as the sorting algorithms I have described.
Sunday, February 9, 2014
Fourth Six Weeks
This six weeks saw what I think of as the first "project" lab: the pong lab. Unlike most other labs where the design of the lab is given to me and all I have to do is fill it in, this lab was much less rigidly structured. The backbone provided was more in the form of functionality than structure, which allowed my partner and me to put together the lab pretty much as we saw fit. However, this freedom also came with challenges. For example, it was very difficult for Ben and me to create the code for the collision detection of the ball. It took us many iterations of code and repeatedly "talking out" our ideas to each other in order to get the collision detection to work property. I think that this was a good exercise, as writing and debugging a tricky bit of code is an important skill to learn. Another aspect of the pong lab that I enjoyed was the bonus problem of converting pong into block breaker. It was fun to be able to reuse so much code to create an game that seems so different from pong, but is really contains very similar components.
Despite all of the things that I enjoyed about this lab, it was somewhat lessened because of the level of abstraction we were working at. We were given how to use the Graphics library and treading without any instruction on what the library actually did or how it did it. I understand how the time constraints of the course limits instruction to only what is necessary for an AP course, but at the same time it is disappointing as a student to be told "No, you don't need to know how it works. Just use it." I know that many students missed important aspects of the lab because they did no know how the Graphics library, such as that the render() method would be called in a loop repeatedly. I am not sure how this could have been avoided, just that it is always disappointing when functionality is hidden.
Despite all of the things that I enjoyed about this lab, it was somewhat lessened because of the level of abstraction we were working at. We were given how to use the Graphics library and treading without any instruction on what the library actually did or how it did it. I understand how the time constraints of the course limits instruction to only what is necessary for an AP course, but at the same time it is disappointing as a student to be told "No, you don't need to know how it works. Just use it." I know that many students missed important aspects of the lab because they did no know how the Graphics library, such as that the render() method would be called in a loop repeatedly. I am not sure how this could have been avoided, just that it is always disappointing when functionality is hidden.
Sunday, December 22, 2013
End of the First Semester
The have thoroughly enjoyed this semester of AP Computer Science. However, there are a few things that I think could be made better about the course. My second semester would be better if you, as a teacher, made the labs more open-ended. While I understand why you provide the framework for the assignments that you do, I think I would learn more if there was greater freedom to make individual programming decisions. One example of what I mean is the last array lab that was meant to demonstrate the difficulties of making arrays dynamic. Most of the problems that my partner and I faced in that lab were a result of us not following the exact prescribed programming method. As the number of tools the class has at its disposal grows, I think the labs should become more and more "high level," where the problem is defined without regard to the individual details of the implementation. Had the last lab assignment been defined this way, I think it would have been much more instructional and I would not have felt frustrated in trying to follow the exact method prescribed by the lab.
I can make my second semester better as a student by helping my partner Ben more. I have a habit of immediately wanting to code a solution to a problem and explain it afterwards, which makes the discussion we then have more one-sided. This also means that I do not get the main benefit of partner programming: having two people look at every line of code and know what it does. Instead, I will verbally explain my proposed solution in order to foster a discussion about what is the best approach and to work out any limitations that we will have to overcome. This will make pair programming more effective.
Saturday, November 9, 2013
End of the Second Six Weeks
The two most important concepts this six weeks were arrays and loops. Knowing both of these allows the programmer to be much more flexible in their approach to a problem, and increased the number of doable problems by a significant margin. Programming problems that mirror those in the real world, such as counting the number of occurrences of specific characters in a file in the Alice Count lab. The extra credit for this six weeks, to make an audio editing program, also felt similar to challenges real programmers face. This was probably the most fun I have ever had doing a Computer Science lab. However, it was also the hardest Computer Science lab I have ever done. The input parsing took me a while to get right, requiring several design iterations even in what kinds of loops I used. But when I finally finished it, it felt really neat to be able to use a program that I had written to do something useful. It is also a big bonus if that "something useful" was slowing down people's voices so they sounded deeper. I had way more fun than I should have doing that.
Another change this six weeks was the introduction of partner programming. Initially, I was skeptical. I thought that having another person program with me would slow me down. I could not have been more wrong. Needing to explain myself to my partner helped me really hone my algorithm design. He was able to catch all of my small programming errors that would have taken me a long time to find myself. He also came up with some really good ideas himself that I would never have thought of. Because we were able to catch each others syntactic and conceptual mistakes, our Word Search algorithm worked the first time we tried it. This is very unusual for a computer lab, but was made possible though the benefits of partner programming. I definitely look forward to working with my partner for the rest of the year.
Another change this six weeks was the introduction of partner programming. Initially, I was skeptical. I thought that having another person program with me would slow me down. I could not have been more wrong. Needing to explain myself to my partner helped me really hone my algorithm design. He was able to catch all of my small programming errors that would have taken me a long time to find myself. He also came up with some really good ideas himself that I would never have thought of. Because we were able to catch each others syntactic and conceptual mistakes, our Word Search algorithm worked the first time we tried it. This is very unusual for a computer lab, but was made possible though the benefits of partner programming. I definitely look forward to working with my partner for the rest of the year.
Saturday, October 19, 2013
Things are Picking Up in CS Class!
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?
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?
Saturday, September 28, 2013
End of the First Six Weeks
In the last few weeks I have begun to come across the many differences between Java and C++. My first taste came with learning string manipulation. In C++, strings were always manipulated indirectly as arrays of characters. The String class in Java hides this internal array in favor of methods such as substring(). This was quite a paradigm shift for me, because I was used to doing all of the iteration and managing indexes myself. In exchange for somewhat less access to the string, string operations are much simpler to use. I hope there aren't many times I will have to memorise the methods of a class, as I find such work arduous.
Objects in C++ are very similar to objects in Java. Both the concept and the syntax are the same. The only difference is that Java hides its references and pointers, while C++ does not. Not being able to pass a pointer to a method seems like it would make some operations challenging. On the other hand, Java's garbage collection means that the programmer does not have to worry about freeing up the memory from a reference/pointer that is not in use. Also, some pointer constructs in C++ could be very confusing, such as a variable that is a reference to a pointer to a pointer (&**var1). When Java hides references and pointers from the programmer it is analogous to putting anti-lock brakes on a car: it makes Java much safer, but at the cost of performance and fidelity. This makes Java an excellent language to learn programming with without getting caught up in the nitty-gritty of memory allocation and deallocation.
Friday, September 13, 2013
The First Three Weeks
The first three weeks of AP Computer Science have mostly been review from my knowledge of C++. Java borrows most of its syntax from C++, so it has been very easy learning about the basics of programming in Java such as variables, operators, and methods. What has been challenging is learning all of the idiosyncrasies of how Java methods handle various types. The worksheets have been very useful in this regard, but I still sometimes have trouble with specific cases. One such case is when a character is added to an integer and the result is printed, for example: System.out.println('A' + 5). The result is an integer, not a character. This is very different from System.out.println("A" + 5), where the output is the string "A5". I am not sure how many of these idiosyncrasies will be on the AP test, but I think I should try to learn as many as possible just in case.
I have also been able to set up the various editors I will use to do labs this year. I had already had some experience with Eclipse, so I decided to use that as my primary editor. The complication with using Eclipse, however, is that each compile unit has to be in its own project. I did not want to create projects for each lab, so I created a generic project called lab where I would do each of my labs one at a time. When I finished with a lab, I saved it into a new .java file following Mr. Steven's naming conventions. I think this will work well for the first labs which are short, but I am not sure that this scheme will work for larger projects. In that case, I will have to create separate projects.
Weston
I have also been able to set up the various editors I will use to do labs this year. I had already had some experience with Eclipse, so I decided to use that as my primary editor. The complication with using Eclipse, however, is that each compile unit has to be in its own project. I did not want to create projects for each lab, so I created a generic project called lab where I would do each of my labs one at a time. When I finished with a lab, I saved it into a new .java file following Mr. Steven's naming conventions. I think this will work well for the first labs which are short, but I am not sure that this scheme will work for larger projects. In that case, I will have to create separate projects.
Weston
Subscribe to:
Posts (Atom)