The Old Intermediate Level

At the old Intermediate level, the focus is still on functional programming with immutable data. However, there is an added twist: functions can now be used as data. Because of this, we introduce anonymous inner classes as a new construct. These anonymous inner classes can be stored in variables and passed as arguments to methods.

Although we allow anonymous inner classes, students still cannot use nested classes or nested interfaces at this level. They introduce a level of complexity in naming and referencing that is best deferred to the Advanced Level.

In addition to anonymous inner classes, several new concepts are introduced at this level. We now allow interfaces, which should be intuitive to students since they have been working with abstract classes at the Elementary Level. In addition, we allow package and import statements to broaden the scope of classes the student has access to (including the Java libraries), and to help them learn how to modularize their own projects. We allow the null keyword to be used and also allow explicit visibility specifiers such as public, private, and protected for all constructs except fields and variables, and the keyword static. However, only fields can be static at this level; static methods are still prohibited. We also introduce casts because they are useful with the Visitor design pattern--frequently the arguments to and return type of visitors is Object, and if a more specific contract for the specific function is known, the data can be cast. Students can also define their own constructors at this level, though they must make sure that all of a class's non-static fields are given a value in the constructor. Non-static fields still cannot be assigned outside of a constructor, and static fields must be given a value where they are defined. All fields are still made final.

The code augmentation is the same as that done at the Elementary Level, except that if a student defines a constructor that takes in all the fields of the class, we do not generate a duplicate constructor, and accessors are not generated for static fields, so static field values are not included in the constructor, equals(), toString(), and hashCode() methods. Students cannot override any autogenerated methods besides the constructor.

Both the Command and Visitor design patterns deal with passing functions as data and should be taught at this level. The Singleton design pattern can also be taught here.