Home → The Classics → Farai's Codelab
Semester of Java Revisited
Published:
When I made the Semester of Java (SoJava) repo, I was taking a Java programming class. I had just learned that teaching people is a great way to learn a concept so that’s what I decided to do. I created a blog called Semester of Java to document what I learned.
I tried to follow a format similar to how Derek Banas makes his. In each of his tutorials, Derek provides a cheat sheet that is well formatted and commented. For instance, he made a cheatsheet for his Fortran Tutorial.Mine? Not so much. One cool thing that I tried to do was provide a link to an online IDE by Tutorials Point where you could run the code without the reader having to set up Java on their machine. Speaking of setup, I don’t provide adequate instructions on how to do that besides telling readers to install DrJava which did everything out of the box.
I started strong in the first few weeks and then I’m not sure what happened. I probably had a depressive episode, but I didn’t pick things up after the fourth entry. The blog used to be on Tumblr but in an initial attempt to try and consolidate my content, I screwed up importing it into WordPress, which screwed up all the formatting.
From all of this, as helpful as I was trying to be, I probably ended up confusing readers more than I helped them. Even looking at it two years later, I can barely make out what I was trying to communicate. For instance, in the file LoopyChoices.java
, I try to explain how loops work. Sadly, my commenting and descriptions were dreadful. Look at this,
//LF Converter
Scanner sc2 = new Scanner(System.in);
System.out.println("\nLet's learn some LF language!");
System.out.println("Give me a file with words in it: ");
String filename = sc2.nextLine();
File file = new File(filename);
Scanner input = new Scanner(file);
System.out.println("Where do you want your new lf language to be? End the file name in .txt");
String output = sc2.nextLine();
PrintWriter outfile = new PrintWriter(output);
String results = "";
while(input.hasNextLine()){
String word = input.next();
Pattern vowels = Pattern.compile("a|A|e|E|i|I|o|O|u|U");//creates a patern
Matcher m = vowels.matcher(word);//finds patterns of the expression vowels in word
boolean hasVowel = m.find();
if(hasVowel){
int start = m.start();//gets starting index of pattern m
String[] toElf = word.split("");
toElf[start] = toElf[start] + "lf" + toElf[start];
word = String.join("", toElf);
}
results += " " + word;
}
outfile.println(results);
outfile.close();
input.close();
What’s an LF converter? What’s this Scanner
and PrintWriter
thing? What does input.hasNextLine
do? In general, what is going on? I guess I’m trying to convert text from a file to elf language where elf language which has me add a bunch of lf
’s next to every vowel. If I’m struggling to understand what I myself wrote, imagine what a newcomer to Java is feeling.
Looking back at this now, as bad as my teaching was, I hope I can be more mindful and work towards explaining things better. That is among the objectives of this blog, but I haven’t done a great job in developing those crucial communication skills.