Java Subroutines

As a high school computer science teacher one of the things I find challenging is teaching subroutines in Java. There are a number of stumbling blocks that I struggle with. But I think it all stems from me feeling like I’m trying to teach curriculum that wasn’t created with an Object Oriented Language like Java in mind.

The way to create small, simple subroutines in Java is using public static methods.

This sample code is from TutorialsPoint.com but it’s similar to what I might do

In well-designed Object Oriented Programming we would normally try to avoid the use of public static methods. I don’t want to create programmers that have bad habits and I don’t want to make it more difficult for them to learn Object Oriented Programming later on. So I struggle with the idea that I’m asking students to create a class that has many public static methods as a way for them to break up their code.

Here are the explicit curriculum expectations that I am working around in grade 11 computer science:

“write subprograms (e.g., functions, procedures) that use parameter passing and appropriate variable scope (e.g., local, global), to perform tasks within programs.”

“apply the principle of modularity to design reusable code (e.g., subprograms, classes) in computer programs;”

The first expectation uses terminology that isn’t relevant in Java – should we really teach new programmers what functions and procedures are if their first language is Java? In Java all methods are defined to return something even if it’s “void”.

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close