1.1.3. Transitioning from AP CSP to AP CSA¶
If you have taken the AP CSP (Computer Science Principles) course and exam you should be well prepared for AP CSA. However, there are likely to be a few new things to get used to. If your CSP class used a block coding language like App Inventor, Scratch, Snap!, or App Lab, you learned to create program structures by plugging together blocks. In Java you’ll find the structures are similar but you’ll have to get used to expressing them in text.
On the other hand, if you’ve previously used a different text-based language, such as Python or Javascript, while you will be used to the idea of writing programs in text you’ll have to get used to some specific details of Java’s syntax.
Here are some tips to keep in mind when you are writing Java code, especially if your prior programming experience was with a block language:
You must spell things correctly, or at least consistently. Unlike in a block programming language where you know you are using the right block because you dragged it from a palette, in Java names are what connect different parts of your program and they need to be spelled consistently.
You must pay attention to case: names that differ only in case—one starting with a lower-case letter and the other with an upper-case letter, for instance—are still different.
Punctuation is important. In particular, most statements in Java need to end with a semicolon (
;
). Leave a required semicolon out and your program won’t run. That’s different than this paragraph which you can still read even though we forgot the period at the end of this sentenceJava is in the family of programming languages that use curly braces (
{}
) to group together statements. The curly brace notation may be familiar to you from the AP CSP pseudocode which uses them in a similar way.You should match the indentation of your code to the structure created by your curly braces. In this book you can use the “Reformat” button on coding activities to make sure they match. Get in the habit of clicking it frequently to keep your code tidy.
Here is a comparison of some App Inventor blocks compared to AP CSP pseudocode and Java code used in AP CSA (open in Google Docs).
And here is a a comparison of code.org App Lab code to Java: