Skip to main content

Writing Expressions in Java (Sequencing Analysis)

note

This page provides an analysis of the sequencing principles used in two modules on Writing Expressions in Java. Find the module starting here.

Writing expressions is fundamental to programming. With expressions, you can perform calculations that are similar to arithmetic that you can perform with a calculator. Expressions consists of operators such as + and operands (such as 1 and 2) that are combined together to express the calculation to be performed.

Typically, instruction in beginning programming does not teach expressions directly. Expressions are taught incidental to the teaching of other programming constructs that happen to use expressions. This results in a haphazard sequencing of instruction on how to write expressions, and consequently, learners may not appreciate the power of expressions and where they can be used in programs. Accordingly, the two modules in this case study (Simple Expressions and Advanced Expressions) attempt to isolate the topic of expressions.

A disadvantage of having the two modules dedicated to the topic of expressions is that the topic has dependencies on other topics, such as variables and classes. These topics may require a lengthy explanation that diverts from the topic of expressions. As such, only some of the dependent topics ar covered in the module, as listed in the following table.

Operator/operandExplanation requiredCovered in modules?
Operand: Read a variable value.The variable must be set to a value first, which requires an assignment statement or an alternative method.Yes, but coverage of assignment statements would digress from the subject of expressions. Instead, the module uses boilerplate code to read input from the user and write that input to a variable. Assignment statements are covered in a future module.
Operator: Call a class methodUnderstand what a class/class method is.Yes; this explanation can be done in a few paragraphs. The ability of an expression to call a class method is powerful, and is worth including despite the explanation needed.
Operator: Call an object methodMore complex as compared to calling a class method. Need to instantiate an object via an assignment statement/variable before making a method call.No, because coverage of assignment statements would digress from the subject of expressions. Calling an object method/using assignment statements are covered in a future module.

As an another usage of isolation, the Simple Expressions module arbitrarily defines simple expressions those limited to one operator and two operands (such as 1 + 2). Not covering lengthy expressions and subexpressions in this module makes it easier to explain the types of the operators and operands.