Paving the on-ramp

Cay Horstmann cay.horstmann at gmail.com
Sat Oct 1 07:23:09 UTC 2022


I would like to point out that in Java-based CS1 courses in US universities, there are typically two kinds of on-ramps, called "objects early" and "objects late". Some instructors care greatly about one approach or the other, and textbook authors (such as myself) produce two versions of their book to support the instructor preference.

The objects late camp would love it if there was no visible class, main and all other methods/fields were static without being so declared, and System.out.println was called println.

The objects early camp would prefer a visible class, with an instance method main (invoked on an instance constructed with the no-arg constructor). System.out.println could be replaced with System.println. But a raw println would be confusing--one must then explain that there is a magic method that is different from the instance methods that they are learning to write.

I imagine that both camps would hope that String[] args can be optional for main.

Objects late:

int count;

void doWork() {
   count++;
   println("Did work " + count);
}

void main() {
   doWork();
   doWork();
}

Objects early:

class Worker {
   int count;

   void doWork() {
     count++;
     System.println("Did work " + count);
   }

   void main() {
     doWork();
     doWork();
   }
}

Cheers,

Cay


Il 28/09/2022 18:57, Brian Goetz ha scritto:
> At various points, we've explored the question of which program elements are most and least helpful for students first learning Java.  After considering a number of alternatives over the years, I have a simple proposal for smoothing the "on ramp" to Java programming, while not creating new things to unlearn.
> 
> Markdown source is below, HTML will appear soon at:
> 
> https://openjdk.org/projects/amber/design-notes/on-ramp
> 
> 
--

Cay S. Horstmann | http://horstmann.com | mailto:cay at horstmann.com


More information about the amber-spec-observers mailing list