Java file management, hall of fame and a nice surprise

In the previous post I mocked the Java app that was hardcoded to use Windows C: disk as the default place to open files.

What then is the recommended way? One is to start looking from the user home directory:

JFileChooser fileChooser = new JFileChooser();

fileChooser.setCurrentDirectory(new File(System.getProperty("user.home")));

Or pick the documents directory. It is also a nice thing to save the selected directory and use that if the user would like to continue with the already selected directory next time.

What else is happening? It is now the last week of the course Data Structures and Algorithms I am responsible teacher. Students have been analyzing algorithm correctness and time complexity, implementing basic data structures, more advanced ones like hash tables and hash functions, binary search trees and binary search.

Lectures addressed graphs and graph algorithms too, but implementation of these was in an optional course project only, Mazes. When students finish that, they can play a game a bit like the PacMan.

They get to choose from two course projects: either that Mazes project or optionally implement the classic task: count the unique words from a book file, ignoring some words from another file. The largest test file is around 16 MB, having almost 100 000 unique words.

Processing the largest file, using naively two nested for loops takes on my Mac Mini M1 with 16MB of memory around two minutes to process. The fast versions (hash tables, binary search trees) take less than a second.

I have implemented several different solutions for comparison with three different programming languages, Java, Swift and C++. Each week in lectures I demonstrated some of these, and in the end we had this table for comparison (sorry, in Finnish only).

Hall of Fame of the different Books and Words implementations. Swift versions can be found from the link above to GitHub.

As you can see, the C++ with 8 threads was the fastest one. Next after C++ came a couple of Java versions. Swift implementations were not so fast as I expected. After some profiling, I suspect the reason is in the way Unicode chars are handled in Swift. All the book files are UTF-8 and students were expected to handle them correctly. I do not like that mostly in teaching programming languages the default is to stick with ascii and conveniently forget the existence of different languages and character sets.

Well, anyways, for some reason, processing these UTF-8 text files takes a lot of time with Swift. Maybe later I have time to find out if the issue is in my code and/or is there anything that can be done to speed things up.

Something very nice happened a week ago — the student guild of our study program, Blanko, awarded me this diploma for being a quality teacher. Apparently they had a vote and I somehow managed to come first this time. The diploma was accompanied by this Italian themed small gift box. A really nice surprise! I was so astonished to receive this, thank you so much if anyone of you is reading!

Nice award from the students for quality teaching.

Work work work

youtube.com/watch

Just checked the first commit date of the completely renovated Data structures and algorithms course repository. It was around December 2020.

Since then I have designed and implemented about ten exercises with unit tests in Java. And two course projects with unit tests. Plus about ten additional demos with Swift. All with commentary and instructions.

In a week the new course begins. I’ve recorded about 20 hours of new lecture materials. Additional videos about graph programming with C++ will be included from last year demos.

One of the reasons for not posting too much lately ?

The video is about one of the course project implementing a graph data structure with various algorithms including Dijkstra’s shortest path finding algorithm. I thought applying this in a game context would perhaps motivate the students to dwell into the world of data structures and algorithms. We’ll see….

Teaching season started

Fall teaching season has started with one old course already ongoing. Devices and networks. My part is the networks, so currently I can focus on two new courses starting in October. Data structures and algorithms is an old course but I’ll take responsibility for it this year.

Another course, Platforms and ecosystems is a new course. Meaning I have hands full in creating material for the new course together with two other teachers. And at the same time, familiarising myself with the data structures course.

For the data structures course, I’ve worked earlier with the demo sorting app implemented using Swift. No time to add additional sorting methods there, but should build it with new Xcode, Swift and iOS 14 to see if there are any (breaking) changes.

What I did recently is that I implemented simple (and stupid) array and linked list classes, both in C++ and Swift, to demonstrate the effectiveness of creating and accessing arrays in comparison to linked lists. Will be using that when discussing why different data structures have different (preferred) usage situations. And that there may be conflicting requirements for the data structure in an app. Then you just have to make compromises.

Another important thing to show to the students is that you need to build the release version before comparing or measuring performance.

Pandemic isolation ramblings

Due to the corona virus pandemic, I’ve been working remotely since the end of February. I felt like having a cold and isolated myself before the University officially recommended that to the personnell. Not having the virus though, but a common cold only. Obviously I cannot be 100% sure since there are no tests available here unless you are critical workforce or seriously ill. So keeping myself isolated just in case, at home.

Luckily the grocery nearby delivers food and their app and website to create the orders works quite well. Today the second delivery is arriving, which should be enough for a week at least. They have a very high load of orders flooding the service. What I usually do is to create an order with a couple of products, select the delivery date about one week later, and then keep filling the order until the day before the delivery. By this day, I already have the next delivery date reserved, with a new growing list of items to order. In this way, we am able to secure the deliveries so that there will not be too long gaps in between.

Since the isolation started, I have continued to offer video sessions via MS Teams and Moodle discussion and chat support to the students in the Software architectures course. Fortunately, the course lectures and exercises were mostly over by the isolation started. Students continue working on their exercise work projects until the end of May. Luckily I have a fast network at home, and even better hardware than at the campus. That large iMac screen has proven to be quite a good a thing to have. Currently I am recoding audio feedback for the first phase of the exercise work projects to the students. The amount of feedback to give could be quite extensive, and text feedback is inferior to audio, in my opinion. Video in this case is not needed since I can easily pinpoint the things I comment by addressing the chapter titles and paragraph and page numbers. Let’s see how this works.

The study program and the research unit are using Zoom video sessions to keep in touch and organize during the pandemic. Probably this will last until summer, but I suspect there will be limitations and exceptional situation even in the Fall semester. Time will tell. University support staff has increased the online training of teachers, providing courses in Zoom on using Moodle, Teams and Zoom itself in teaching.

I’ve started to implement a small app with Swift to learn something new. The app is also something to use as a demonstration in Fall in the Data structures and algorithms course. I will take charge of that course after the summer break, so wanted to do something related to the topic.

Below is a demo video of the app in the early phases. I am planning to implement maybe a couple of more sorting algorithms and improve the graphics and usability of the app. YouTube is full of these kind of videos, so I will not put too much effort on this, like implementing tens of different algos.