Preparation for Option D, Object-Oriented Programming in Java

Students going into the IB Computer Science programme, particularly if it’s HL, will benefit from an understanding of the basics of Java programming and the ability to code simple programs before class begins.

On of the best online courses I’ve found are by a guy called John Purcell from Cave of Programming. His Youtube Java course is here:

If you sign up on his site, then you get to discuss the course with other users and perhaps even ask John questions.

https://caveofprogramming.teachable.com/p/java-for-complete-beginners

If you cover these lessons before you start the IB Computer Science course you will be very well prepared. As you can see they’re not very long. You will need to have an IDE installed. John uses Eclipse, which is certainly a good IDE, but most IB teachers tend to use Netbeans in class. My personal preference is IntelliJ.

These are the videos that have most relevance to the IB course. Those with asterisks are not directly examined but are useful for making working programs.

  • A Hello World Program (4:46)
  • Using Variables (7:53)
  • Strings: Working With Text (9:21)
  • While Loops (7:15)
  • For Loops (9:28)
  • If statements (12:26)
  • Getting User Input* (8:52)
  • Do … While (8:05)
  • Switch (6:52)
  • Arrays (9:46)
  • Arrays of Strings (8:39)
  • Multi-Dimensional Arrays (13:06)
  • Classes and Objects (11:44)
  • Methods (11:05)
  • Getters and Return Values (10:31)
  • Method Parameters (15:00)
  • Setters and “this” (10:57)
  • Constructors (10:18)
  • Static (and Final) (19:46)
  • String Builder and String Formatting* (19:43)
  • The toString Method (11:06)
  • Inheritance (14:09)
  • Public, Private, Protected (19:57)
  • Polymorphism (10:04)
  • Encapsulation and the API Docs (11:17)

Using JavaFX for your IB Computer Science IA

If you are comfortable using IntelliJ with/without Gradle or Maven then fine, but I find that sometimes these tools mask what is going on behind the scenes. For that reason, I often like to use a simple text editor for small projects. To get JavaFX working without a build manager, follow these simple instructions.

Download a version of JavaFX. I downloaded the Linux SDK (version 12) from here: https://gluonhq.com/products/javafx/

Unzip it to a place on your file system that you use to store java libraries. I just put mine in my home directory.

Create Main.java with the following code:

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;

public class Main extends Application {
    public void start(Stage stage) {
        Scene scene = new Scene(new Label("Foo"));
        stage.setScene(scene);
        stage.show();
    }
}

 
In order not to have to make changes to your CLASSPATH you can add arguments to the compiler and the JVM.

Compile with

javac --module-path ~/javafx-sdk-12.0.2/lib --add-modules javafx.controls Main.java

Run with

java --module-path ~/javafx-sdk-12.0.2/lib --add-modules javafx.controls Main

Other modules may be required as you use more features of JavaFX.

IB Computer Science IA: Word Count Advice

The word count is 2000. If you go over this then the moderator has the right to stop marking the extra. Some parts of the IA have no word count but there are nuances.

What is not included in the word count:

  • The success criteria (in Criterion A)
  • The record of tasks (Criterion B)
  • The design overview (Criterion B)
  • The video, obviously (Criterion D)

This means that the only parts of the IA that do have a word count are:

  • Criterion A (all except the success criteria)
  • Criterion C
  • Criterion E

Since Criterion A and Criterion E are both worth 6 marks, and Criterion C is worth 12 marks, it makes sense to divide the word count accordingly:

  • Criterion A and E: 500 words each
  • Criterion C: 1000 words

A few words of advice:

  • Source code should be included in an appendix and obviously does not contribute to the word count.
  • Diagram annotations will not contribute to the word count unless they are flagrantly being misused to cram in extra content.
  • The design overview (Criterion B) should not include extended writing; it should be mostly diagrams, tables, schematics, flowcharts, pseudocode, etc. If you add a lot of explanatory text to Criterion B then the moderator is free to add it to the word count.

Please free to ask any questions in the comments section.

IB Computer Science Case Study 2019: A Word of Warning

When students are faced with a research task, a common strategy for weaker students is to just “google it” and take notes on the first few search results. Another poor strategy that affects IB Computer Science students is to exclusively revise from one IB Computer Science website, on the assumption that everything on it is correct.

While examining this year’s Case Study, “A new computer aided dispatch system for Bangbai”, I found that a great many students were giving the same, wrong answers to some of the questions. In some cases students were giving the same answers, word-for-word.

I decided to see if I could find where these answers were coming from and I tracked them down to one IB Computer Science website. Reading through the case study notes on that site, I found a whole range of notes that were quite wrong. It is bad luck that a question came up this year on which this website’s notes were particularly bad. I won’t reveal the question or the name of the site but suffice it to say that I have awarded zero marks to literally hundreds of students this year because they wrote down, word-for-word, what was written in the case study notes of this website.

To students, please use a range of sources and cross-check them. Make sure in particular that the definitions you find are correct in the context of the case study.

To teachers, please continue to share your notes online, but be as careful as you can to make sure they’re correct and urge students to use a range of resources.

The Halting Problem

Is it possible to write a program A that takes another program B as input and which determines if B will halt or loop forever?

Well it turns out that an assumption that the answer is “yes” leads to a paradox and hence there is a proof by contradiction that the correct answer must be “no”.

The proof goes like this:

Assume program A can determine if program B will halt or loop forever.

Now I write a program C that calls program A as follows:

B = input_program
if A says B will halt then
   loop forever
else
   stop
end if

And I now feed program C to itself as input.

The result is that if C will halt, then it will loop forever, but if it will loop forever, then it will halt.