Object-Oriented Programming and the Purpose of Government

I’ve tried to talk about politics with people I’ve just met. I’ve also tried to talk about computer science. Hopefully this post will be a case of two wrongs making a right.


I recently decided to learn the Java programming language. After picking up a trusty Dummies® book, I jumped into my comfy chair and began to read. A few hours later, the important details and syntax of the language had quickly fled from my mind, but an intriguing concept stayed with me. It was the idea of putting limits on what parts of code can be accessed by other parts within the same program. At first, this seems a little strange, almost like sealing a Lego tower in plastic wrap; much like this creation could then never be changed, certain portions of code in Java can never be altered when the program runs. However, this rigid organization is ultimately what makes object-oriented languages like Java the coding mediums of choice for millions of programmers.

With designations like “public”, “private”, and “protected”, these scripts seem to be big on security. However, their authors’ intentions are not to prevent hackers from infiltrating the programs; they are to prevent themselves or their colleagues from making changes in the code. Why is such self-restraint necessary? Consider the situation of an undisciplined programmer named Sloppy Joe. In 2006, Joe wrote 500 lines of public code that was meant to make a ball bounce across his screen. It worked quite well, so Joe decided to expand on the code by writing new programs that referred back to the old file. He did this multiple times, exploring all of the exciting possibilities that follow from being able to bounce a ball, and created many new files that all referred to the original file.

Then, in 2012, Sloppy Joe decides he wants a program where a ball spins in a spiral and then explodes. Being lazy, he goes back to the first old file and changes a few things to get his desired result. Everything seems to be going smoothly until he remembers all of the programs he wrote that refer to the original. He opens them slowly, and to his chagrin, he finds some to now have exploding balls, and some to not work at all.

“Joe isn’t just sloppy, he’s stupid! An intelligent programmer would remember all of the programs that refer to the original and leave it untouched,” one might scream in frustration. However, professional geeks like Joe often write hundreds of lines of code on a daily basis. As years pass, there’s no way they’re going to remember the relationship between every program they’ve ever written. It’s much safer and smarter to build protective mechanisms into the code as it’s being written. Despite what some AP Computer Science students might think, the creators of Java didn’t require “public” or “private” designations out of mistrust for the students. They required them to free programmers from the burden of constantly remembering the details of every piece of code, and to ensure that the original intentions of the programs would be preserved.

Such is government.

Oh, I guess that requires a little explanation. In many ways, the relationship between government and the individual is analogous to that between a computer program and its author. Individuals create a government in hopes that it will serve functions that they don’t want to always have to do themselves. For example, governments will often test the quality of food or water, protect the environment, and try and punish criminals. Individuals are capable of doing these things themselves, but they don’t want to have to worry about them on a daily basis. Thus, they set up organizations to worry about these things for them. Or in terms of Java:

 * @author Collective Individuals 

public class Government(int money) {
  private FDA = new Organization();
  private EPA = new Organization();
  private justiceSystem = new Organization();

After the creation of these organizations, the only easy way they can be affected is by changing the amount of money that gets funneled into them. Rewriting the program to remove the “private” organizations can be not only tedious, but also risky, as legislators have to consider every group of people that are affected by the existence of these organizations (including future generations). They also must remember the original intentions of the organization, and prove that those aims are no longer necessary or relevant. Thus, the founding fathers of the United States — and the creators of Java — were quite wise to institute safeguards when outlining the rules for legislation and programming. For the former, these protections came in the form of checks and balances. For the latter, they came as public, private, and protected access modifiers.

Another parallel between object-oriented programming and our legal system is their use of precedence. As I alluded to before in the Sloppy Joe example, Java coders build on previously written scripts every time they write a new program. This is called “extending a class”. Similarly, judges always look for a legal precedent to base their opinions on; this is often referred to as “extending a previous ruling”.  The best judges and programmers cringe at the thought of going back and changing the original codes on which they base their works. Though operating strictly within these frameworks may seem constricting, they realize that their codes have much greater value if they are unable to easily discard them tomorrow.

In both programming and government, we can’t afford to routinely start from scratch. To delete or edit source code in Java is like trying to grow a tree and then cutting it down every time it sprouts. Similarly, to ignore legal precedence and government development would be taking our country decades or centuries back in time. Those who argue for government “reform” in the form of broadly cutting funding are using a bazooka when they need to be thinking in terms of a scalpel. Surely, there is wasteful government spending and ineffective publicly-funded programs. But when you want to free up space on your computer, do you blindly delete large programs without considering what files might depend on them? Politicians should take a page out of the Dummies®book and focus on making classes “protected” — not just from terrorism or threats of violence, but from the politicians themselves.

This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s