Creating Hello World in Java (Sequencing Analysis)
This page provides an analysis of the sequencing principles used in the Hello World in Java module. Find the module starting here.
Sequencing principles used:
Background
Java is used in some courses that teach beginning programming. An argument against learning Java is that it forces the learner to use the object-oriented paradigm, even if in a minimal way. This paradigm is good for managing the complexity of larger programs, but adds unnecessary complexity for beginners who are writing hello-world style programs.
Object-orientation creates a distraction for beginning programmers; they should learn about more primitive programming concepts such as statements, variables, and expressions before dealing with objects. Also, in the beginning, students will write smaller programs where object orientation isn't needed.
The ideal Hello World program
We would like the hello world program to demonstrate only these concepts:
Hello World
is printed firstHello World 2
is printed second (To demonstrate that lines in a program run sequentially)
For example, a Python program can be written that only demonstrates those concepts:
print("Hello World")
print("Hello World 2")
A Java hello world program cannot be written that only demonstrates those concepts, as shown in the next section.
The complexity of Hello World in Java
Due to the verbose nature of the Java language and the requirement to write programs in thh object-oriented style, Hello World in Java is more complex than in Python:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello world");
System.out.println("Hello world 2");
}
}
When trying to understand this program, the learner will have these questions about the following concepts that are not part of the ideal Hello World program:
- What is a class and why is it needed?
- What does
public
mean? - What does
static
mean? - What does
main
mean? - What does
String[] args
mean?
Following are three possible sequencing approaches for teaching how to write this program in Java.
- Approach 1: Do not answer these questions asked above, and tell the learner to ignore the first two lines. For the
System.out.println
, command tell the learner that the meaning of the periods andSystem.out
will be explained later. - Approach 2: Summarize what a classes and methods are, and why the main method is needed. For the
System.out.println
, command tell the learner that the meaning of the periods andSystem.out
will be explained later. - Approach 3: Explain the classes/methods concepts more completely, including the meaning of the keywords such as
public
,static
, and the periods inSystem.out.println
.
Approach 1 most closely follows the isolation principle. This case study takes approach 2, which uses the exposure principle by summarizing what a classes and methods are, and why the main method is needed. This comes at the expense of not completely applying the isolation principle.
Taking approach 1 or approach 2 is recommended. Approach 3 is not recomended. because a complete explanation of the Hello World program would overwhelm the learner.