AP Computer Science A has some problems.

For the past 20 weeks, I’ve been taking AP Computer Science A through the Virtual High School. I wanted to take this class as I was interested in the online class experience, and also get some Java experience under my belt.

While the actual class on VHS has been very good, I have some problems about the way the CollegeBoard wants to teach AP Computer Science A (which will be referred to by APCSA for the rest of this article). Here are my thoughts.

 

Some background

I’ve been a developer for about 3.5 years as of writing this article. In that time, I’ve written a solid amount of programs in Python and for the web, ranging in complexity from very simple to somewhat advanced. I consider myself to be a developer full-time (although school takes away 10 hours/day but shhhhh).

I went into the APCSA class knowing that I was a developer, and that I’d have a much different viewpoint on the class compared to someone who wasn’t a developer beforehand.

Do I regret taking APCSA? Mostly. I’ve been able to gain some of the basics of Java, which is awesome, but just don’t really give a shit about the rest of the class because of the boneheaded ways the AP wants you to code. So, here we go.

 

Problem #1: Code styling

Code is like an art. We all code in different ways. I personally code like this in JavaScript:

if (x == y) {
console.log("Yes")
} else {
console.log("No")
}

 

However, this is how the AP wants you to code, using the same example in JavaScript (the basic syntax is the same):
if (x == y)
{
console.log("Yes")
}
else
{
console.log("No")
}

Now, I mostly have a problem with how the AP teaches you to code. Not only does it take up more space (8 lines vs 5 lines), when you’re writing out the code examples by pen, you probably want to be more efficient with your code styling. I personally write big, so for me, using the first style makes more sense.

The AP doesn’t explicitly take off points if you code like a normal human being, but the VHS course does! I’ve gotten points docked on assignments because I get to format my code in the special AP way for…whatever reason?

Coding is art, and you should code how you want to. That includes giving credit for the same code, that does the same thing, that uses less lines of code.

 

Problem #2: Restricting use of libraries…and a lot of them

Here’s a fun question: How often do you use a language’s built-in rounding system? Pretty often, I would assume. Unfortunately, for some dumbheaded reason, the AP does not allow the use of Math.round (which is the Java equivalent of rounding) in the exam.

Same goes for a lot of pretty common Java methods, such as:

  • No weak typed variables (var is not allowed)
  • You can’t use most of the String class (including charAt, codePoint, contains, startsWith, isEmpty, lastIndexOf, split)
  • You can’t use most of the Array class, too (including compare, equals, mismatch, arrayscopy, lastIndexOf, toString, sort, fill, split)
  • The char type of variable
  • Ternary Operators

Now, you’re probably asking, why the fuck don’t they allow it?

Because they want you to learn how rounding works without taking the shortcut. Yes, this is a viable teaching strategy, but at the end of the day, I personally prefer the learn how to do it manually than go the shortcut route (a better example of this is at the bottom of this problem section).

 

Here’s a few examples of the AP bullshittery that I get to deal with.

Example 1: Finding the character at index 5

Let’s assume I have a String named name declared with the text “Python”. I want to get the character at index 5.

Java has a charAt method, which returns the char at index 5 (in this case, n). But, because char is not allowed, instead of doing this:

System.out.println(name.charAt(5))

I have to do this:

System.out.println(name.substring(5, 6))

 

Still 1 line of code, but more code to type out.

Example 2: Copying arrays

Let’s assume I have an array named arr1 and arr2. I want to copy the contents of arr1 to arr2.

Java has a copyOf method, which can perfectly copy arrays (System.arrayscopy also exists, but I’m using copyOf in this example). But, the AP does not like efficiency (since when did the AP ever like efficiency, to be honest). So, instead of doing this:

arr2 = Arrays.copyOf(arr1, arr1.length)

I have to write a for loop to individually copy each element of the array that takes up so many more lines of code it isn’t even funny.

Now that’s certified stupid.

Example 3: Filling an array

In the forbidden AP methods resource for VHS, they say that the fill method is not allowed. The reason?

“Fill an array yourself.”

That’s the equivalent of having a ladder on the side of a building, but then an invisible ladder moderator saying “Build a ladder yourself.”

Example 4: Ternary operators

Ternary operators are pretty cool. In short, it’s a one liner of code that allows you to set a variable by using a comparison operator, and setting the conditions for true and false. Works something like this:

variable = condition ? variable if true : variable if false

As an example, I have a variable x that is declared, and a variable y that is declared. A user inputs a number to y. I want to make it so that if y is greater than 10, x is y * 2. Otherwise, x is y * 0.5.

Because again, the AP doesn’t like efficiency, instead of doing this:

x = y > 10 ? y * 2 : y * 0.5

You have to write a whole if block that I’m too lazy to write.

Again, more lines of code, more chances to screw up.

Example 5: Comparing arrays

Java has a pretty cool method that allows you to easily compare arrays. If I have two arrays, arr1 and arr2, and wanted to compare them, I just have to type this in:

Arrays.equals(arr1, arr2)

However, the AP wants you to code an entire for loop, constantly checking if array elements equal, and setting an external variable equal if they’re not. And, since the break element is forbidden, you have to loop through every single element.

 

In short, these methods are actually very useful ones in the real world. I understand some of the logic behind not using them as they can get pretty complicated (especially Ternary operators). However, I feel as if students learn how to do it manually then using the “shortcut” way, it’s a happy compromise.

It’s sort of like deriving the Pythag theorem equation to use it. In APCSA land, you need to derive it every time, even though you know what the equation is at the end of the day.

Problem #3 – Excluding some pretty important material, and overriding some other important material

The AP CS A exam, like any other AP exam, decides to throw out some pretty crucial information that I would consider fundamental to the Java language as a whole. Let’s go down the list, shall we?

  • Binary, Octal, and Long variable types are not covered. Long is pretty important if you’re dealing with big numbers since Java has actual number limits if you get into the whole big data shebang.
  • Prefix compound operators are technically allowed but super frowned on. So are compound operators inside expressions are also not allowed (which I get can be confusing, so I’ll let it slide)
  • Switch statements
  • Conditional operators
  • More specific Math methods that aren’t pow, random, sqrt, abs, which I guess I can let it slide.
  • Escape characters that aren’t \\, \n, and \”.
  • Char type is not taught, which is the equivalent of skipping over a pretty important variable type.
  • Do while loop is skipped, which in my view, is more important than a for loop because of the potential efficiency savings it brings.
  • Break, continue, and switch are skipped in for loops. I use break and continue all the time, these are very important things to know with loops!
  • The arraycopy and clone methods, as mentioned earlier.
  • Deeper stuff with 1D arrays such as variable length arguments.
  • Ragged 2D arrays. It’s not a perfect world out there, you’re going to deal with ragged arrays at some point, this is just plain stupid.
  • 3D arrays are skipped. 3D arrays can be important in some use case scenarios, but mostly follow 2D arrays (just 1 layer deeper), so I’ll let it slide.
  • You’re not allowed to access instance variables from a class by using ClassName.variablename. Instead, you have to make all of these private, and create get/set methods to set/get these variables.
  • Protected visibility is skipped. I think it’s pretty important, not sure.
  • Date, Random, and Point2D pre-defined classes, which are useful in some circumstances.
  • Abstract Data Type
  • Aggregation Associations is replaced with HAS-A. In short, object HAS-A int. Don’t ask me why!
  • Probably more

Generally, I can pin this down to that this class is being taught at a High School level, and with limited time. However, some of this is pretty important to getting a solid foundation of Java. Sure, it isn’t required to know the basics of Java, but all of this information is good knowledge that will better equip a newcomer to Java when building programs later on in life.

 

Summing it all up

What I’ve found in my quick in-depth analysis of AP CS A is that the College Board (the folks who run APCSA) are more focused on actually testing you on Java, rather than actually teaching you how to be a programmer. This is an issue, as AP CS A is quickly becoming the first exposure that a lot of newcomers have to the world of coding.

Coding is profoundly based on problem-solving skills. You can know all the syntax you like in the world, but if you don’t know how to effectively solve problems, you’ll have a tough time coding. You need to know how to use Google to quickly find an issue, and how to effectively use Stack Overflow.

Same goes for debugging, which is a subset of problem-solving skills. You need to know what the compiler is telling you, and how to use that information to fix your code. You need to know how to find logic errors in your code, which can be a pain in the ass sometimes.

 

My ideal programming class is one where you’re taught a certain subset of functionality, then told to go make your own shit using that functionality. It’s creativity, problem-solving, and freedom all at its best. Unfortunately, AP CS A is mostly copying code from the textbook, modifying it to “make it your own”, and then uploading it. To newcomers, this is magic, which is great. However, to developers who have more than 6 months experience, this is torture. I cannot stand just copying and pasting code, following rigid instructions, and uploading it at the end of the day. To what benefit does that have to me?

There is Pearson MyLab that the VHS course uses which does allow more creativity, giving you an end goal of what to accomplish at the end. These problems I like more, since I can have a bit more creativity with how they’re being coded.

 

In short: Should you take AP CS A? No. I would strongly recommend against this. I would instead recommend that you learn how to code yourself. Start with a simple language, be it JavaScript or Python. Take a 1-week course in the fundamentals of the syntax and get to know the language. From there, do whatever your heart desires. It’ll be tough in the beginning. Problem-solving doesn’t come easy to everyone. But, if you keep making dents at it, you’ll get really good at coding.

Syntax is 50% of coding. Problem solving is the other 50% of coding.

And the College Board is only teaching you 50% of the story.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.