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.

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