Friday, September 11, 2020

Java Is as Java Does

We would not seek a battle, as we are;
Nor, as we are, we say we will not shun it.
Henry to Montjoy,  Henry V,  Shakespeare

Kenneth Branagh's Henry V: right royal entertainment ...

Last season I (Howard) was not very active in FTC Robotics, and it turned out to be a fascinating year - new leagues, new competition formats, and just when it was getting into the home stretch, it got locked down - hard.   Along with nearly everything else.  None of us saw that coming a year ago.

So here we are at the start of a new season, and not a one of us knows what will happen over the next 4-5 months.   That's actually OK, and more to the point, it's what King Harry was driving at in that quote: "our present condition may not be to our best advantage, but regardless of our present condition we'll take it on."

In a normal year we'd be meeting in the shop and using shop computers and doing a lot of loud talking to be heard over the shop noises.   This year, we're starting "virtual" or on-line, and that creates both challenges and new opportunities.

Virtual practices are a new thing for us, and it's probably good and bad in equal measures.  The face to face interaction, the whiteboard sessions, and some of the subtleties about mapping a real world into a virtual space don't happen easily in a virtual session.   BUT, nobody needs to yell to be heard over the shop tools, and I think we can do some interesting things.

Elsewhere in this blog you'll see my fondness for the Raspberry Pi as a learning tool.  (link to blog post here)  The humble Pi was built for this job, and the default Raspbian OS has, for years, included both Python and Java development tools.   Java, as you no doubt recall, is the language we use for programming the robot.  One of those Java development tools, also available for Mac, Linux, and Windows, is BlueJ.


Now I'm not saying, or even really recommending that everyone go install BlueJ or Greenfoot, especially since we're doing most of our development on Android Studio, but let's be candid.  Android Studio is kind of a hog.  If you ask it how much memory and processor it needs, it'll burp like Jabba the Hut and say "MOAR" without even a please.   BlueJ is lighter (it runs on a Pi, for goodness sake), and for experimenting with some ideas or just learning some aspects of programming in an object oriented environment, it has some really neat features.

One of those features is that it allows you to run a small method (like a subroutine, but only if you're REALLY old) all by itself without having to run the whole program.   Here's a screenshot of how that looked at a recent practice.


BlueJ itself is available from https://bluej.org/  as is a usable set of instructions and links.

It, like the Pi, was developed as a teaching tool, so no surprise that several tutorials on how to use it come from various universities.  I've used this one, but there are others:   https://www.cs.utexas.edu/~scottm/cs307/handouts/BlueJProjectInstructions.html 

While the next couple of sessions will have a strong focus on reinforcing the basics - data types, good structure, use of methods, and probably an introduction to classes, my strong sense is this:

The mentors (including me) need to start thinking about how to test small snippets of code, and how to teach the students to do this.   Shop hours will be precious, and every single bug we can get sorted out before heading downtown will pay us back by the bucketful. BlueJ allows running just one function at a time pretty easily and that, my good people, is power we can use.

If you want to use and extend some of the code we worked with earlier, I've put it on GitHub here: https://github.com/50N40W/javacode/tree/master 

But it's always worth remembering that while the details of a language are necessary, the discipline - and yes, beauty - of a well constructed program transcend any specific language.





Java Is as Java Does

We would not seek a battle, as we are; Nor, as we are, we say we will not shun it. Henry to Montjoy,   Henry V ,  Shakespeare Last season I ...