Monday, May 26, 2014

The Year in Review

This year in Advanced Placement Computer Science has been a fun and informative experience. Entering the class, I was not sure how helpful it would be in improving my programming skills, as I had learned C++ in the past. However, it turned out that I have learned a lot from my experience with Java. Besides re-introducing me to programming syntax, this course has improved my problem-solving skills and introduced me to many new experiences, particularly in the form of contests.

The USA Computing Olympiad in particular, which I was introduced to through this course, has been a source of both joy and frustration throughout the year. Another competition I enjoyed was the HP Code Wars contest, which was fun because the people in my group were all very easy to collaborate with. Finally, the High School CTF contest had me questioning whether the contest organizers had made the problems solvable. In all, I enjoyed the computer science contest opportunities I had this year and feel that I am a better problem solver because of them.

As fun as the contests were, my favorite experience with computer science this year was during the free time I got at the end of the year to pursue my own interests and projects within computer science. I chose to follow an online tutorial that promised to teach C as a second programming language in order to create a Lisp environment. While I enjoyed the challenge of programming in a different language, my favorite part of the project was that it pulled together so many different computer science topics in a new and interesting way. For example, I had to learn regular expressions in order to write the rules for the parser. Then I had to apply my recursive programming abilities to write code to evaluate the tree produced by the parser. While I am nowhere close to completing the tutorial, I plan to continue on my own time because of how much fun I had doing it. While the level of self-teaching the project requires might not fit well for all students, I would be interested to see if there were a way to integrate some of the inter-disciplinary work from this project into the APCS curriculum.

While I enjoyed the vast majority of my time in this class, there were some parts that I did not enjoy. One of these was GridWorld, which will thankfully never haunt APCS students in the future. My major gripe with GridWorld was how random and fake it felt. I did not feel that I was learning computer science skills that would be generally applicable, instead I felt that I was being forced to become familiar with and in some cases memorise information that was arbitrary and useless. I understand that students must be taught how to deal with libraries of existing code, but I see no reason to make the teaching library so unrealistic and frustrating. The lab assignments for GridWorld were also very annoying. Unlike every other lab for the whole year, the most difficult part of GridWorld labs is figuring out how the library is put together, and writing a few lines of code to access existing functionality. There is no problem solving, no challenge, in these labs, which means that I find them boring. I understood why I needed to do such labs: the information would be on the AP test, but I still strongly disliked them. Luckily next year’s APCS students will not have to undergo the pain and torture of GridWorld.

One thing that made the GridWorld labs manageable was the partner programming system. Because so much of computer science is about solving problems, having two people work on the same problem together leads to better solutions more quickly. I definitely appreciated having a partner to bounce ideas off of and to catch my mistakes, of which there were many. For example, it is very easy for me to make a small mistake such as decrementing a variable instead of incrementing it, or forgetting to reinitialize a variable, that my partner catches when it would have taken me half an hour of debugging to find it. In addition, he often thinks of solutions that I would never have thought of, or takes my solution and makes it better. Overall, having a partner programmer has made the year a much more enjoyable experience.

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.

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.

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?

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.