During my last year of high school I took AP Computer Science. It sounded interesting, but prior to the summer homework assignment, I wasn’t sure what it would be about. At the time I had ideas that it could have been a general, basic class about how all the hardware worked together, or maybe it would be an introduction to software assembly, about all the bits and bytes in computing.
I was fortunately wrong. The class is simply an introduction to Java. It taught me the basics of Object Oriented Programming (OOP) using a language I have grown to call my favorite language. Through Cay Horstmann’s 4th edition of Java Concepts, the class taught:
- Basic Computer Hardware (CPU, RAM, etc)
- Objects and Classes
- Data Types
- Flow Control (if/else, loops)
- Arrays and ArrayLists
- Interfaces, Inheritance, and Polymorphism
- Searching and Sorting Algorithms
The above mentioned topics provide a great foundation for Java Concepts. Since a lot of the material in the class taught the underlying concepts of the programming constructs in computer science terms, it is easy to learn new languages after that (something I would assume that students starting with Python would have a harder time doing – I’ll elaborate on this in another post).
While these topics are crucial to programming, other topics had to be cut from the AP curriculum. Though none of the following topics are presented in the AP test, they appear in the textbook and were skipped (at least at my school).
- Reading and writing to files
- Event Handling
- Graphical User Interfaces (GUI’s)
- Anonymous Functions and threads
- Advanced Programming Constructs
* My class did a graphics project and a 3D world project; however we just either used basic API’s or following a template. This was not covered on the AP test.
In addition to these concepts inside Java, there’s a lot more to learn about importing libraries and using the nice features of IDEs. Since this is just a concepts class, it’s completely reasonable that we only used BlueJ rather than an bona fide IDE. So in addition to the Java concepts missed in the book, here are some general very useful programming ideas that aren’t covered:
- Programming in another IDE
- Compiling and running without an IDE
- Importing libraries (using other peoples’ code)
Rather than go in depth about each of these topics now, I may have upcoming blog posts about some of them if there are requests in the comments. Instead, I’ll just give a brief summary and useful cases for each one.
While debugging throughout the class, we find ourselves hearing the word “exception”, most commonly in the IndexOutOfBoundsException. We all know it’s an error, but why does the program crash, and how can I make my own errors?
Well it’s not too hard to do this. You can make your own exceptions for when a person operates your program and it spots something that could mess things up. Oracle provides a neat little lesson on exceptions that could help you hit the ground running.
Reading and Writing to Files
Files are a very important idea in computer science. They allow users to save, edit, and delete information with ease. When we start our track in computer science we’re given a console and must copy and paste data that is produced using our programs. What if you could write a program that instead saves it in a file automatically (automagically?)? Well, Mkyong has an amazing Java I/O Tutorial that could save you time and hair on your head that otherwise would be pulled out from errors!
Event Handling and GUI’s
Once again, in this class we basically deal with command line interface, or line user interface (LUI) rather than Graphical User Interfaces (GUI). Since it’s just a linear program, the applications you’re writing aren’t event-driven.
The default Java GUI elements now use the swing interface (previously the AWT package). It has grown to encompass a bunch of options and lets you make programs that don’t strictly use the command line. Oracle made a Getting Started Guide that you might want to check out!
A generic is basically only seen in this class when dealing with ArrayLists. Remember when you used those angle brackets, like in
ArrayList<Object> = new ArrayList<Object>();
Well those angle brackets are an indicator of generics. Generics allow you to use any object you want, sort of like how objects can implement interfaces. Are you buying this? If not, or if you want to learn more, check out Oracle’s own explanation in their page, Why Use Generics?
Anonymous Functions and Threads
Ooh, thread. That’s a word you may have heard, have a vague idea of what it is, but never bothered to look up what exactly it was.
A thread allows you to simultaneously have two paths of execution at once, sort of how a multi-core processor can run more programs at the same time. Threads are best used when you have an algorithm that could make use of parallel computing, in which multiple process threads work together to solve a problem. Also, threads could be used to make a video game, since you can make it update every one sixtieth of a second to produce a 60 FPS game in a Java applet, for instance. Learn about threads in Oracle’s Lesson on Concurrency.
Anonymous functions are used often when creating threads. Basically, you can create an object of a particular interface and override the method on the spot! That method is an anonymous functions. In other languages, such as python, something similar could be a lambda expression.
Finally, we’ll be talking about graphics, the most exciting part of programming (we think). There’s tons of ways to implement graphics, but Java does a great job of standardizing itself with its own sort of graphics libraries, mostly in the form of Applets. There’s so much to cover here that I’m just going to send you to Oracle’s Lesson on Graphics that will teach you a lot of the basics that will allow you to start drawing!
Advanced Programming Constructs
This section should realistically be titled “Advanced Data Structures,” but I already named it in the beginning so we’re sticking with Advanced Programming Constructs! So after this class, you know what arrays and ArrayLists are and the benefits and drawbacks of each of them. Arrays are super primitive and you have to do a lot of work to add space in them or shrink them. ArrayLists on the other hand seem to have all this under control, with everything happening delightedly under the hood. While under the hood, it could get pretty messy (I mean it’s really just an array down there if you think about it). Once you have a huge array of ArrayList it could be disgusting trying to increase the size. The computational complexity just goes through the roof.
Let me present to you: the LinkedList, another Java collection, which instead of having an array-backing, has links that are scattered in memory but could refer to each other in a single or double or n-linked fashion. This allows you to expand or delete a value in your list with almost no cost.
As the title of this section states, these are for advanced users that want the most out of their code. If you’re looking to get a head start and open your mind to the goodness of other kinds of data structures that arrays and ArrayLists, take a look at Java’s very own LinkedList API and then maybe gleam your eyes over some other Data Structures.
The reason why they are called advanced is because it’s good to know the underlying implementation, which will allow you to know when to use which data structure.
IDE’s , IDE-less coding, and libraries
I will have a blog post soon about all 3 of these, but if you are interested in IDE’s you should type Eclipse or IntelliJ into Google.com’s search bar and you’ll be in IDE heaven.
If you’ve made it this far, I hope I have expanded your mind on some of the other important parts of programming that are staple in any developer’s toolbox. If you are interested in a certain one of these topics, or if I missed something big, please leave a comment and I might just write a post explaining it.
If you learned something in this post, and you’re interested in programming and/or gaming, be sure to subscribe to the newsletter to be notified when I make my next post (it’s free)! Thanks, and happy coding!