Cover during TOK presentations

Wednesday 30th September

Block C, Grade 12 Computer Science

IAs! Please make sure you make some additions to your Record of Tasks. You should be nearing completion of Criterion B now. Criterion C will take you almost up until December.

Block D, Grade 10 Computer Programming

Continue with Scratch game. You have until the end of next week to finish it, so that makes only 4 more lessons including this one. Next Friday you will make a video of your working game, so be prepared for that.

Block E, Grade 9 Animation

Continue with the work set by Ms Wong.

Thursday 1st October

Block B, Grade 11 Computer Science

HL: Consolidate work on binary trees including notes on the website. Go through Topics 4 and 5 in the guide and make a list of any areas that you are unsure about. Bear in mind that everything you cover in Topics 4 and 5 you also need to know as part of Option D (ie you need to be able to do it in Java) We should have largely covered both of these topics by now. If you have time, use Blue Pelican Java to investigate the topics of Inheritance, Encapsulation and Polymorphism in Java.

SL: Ensure that all of your notes on your websites are up-to-date. Go though Topic 4 in the guide and make a list of any areas that you are unsure about. Bear in mind that everything you cover in Topic 4 you also need to know as part of Option D (ie you need to be able to do it in Java). If you have time, use Blue Pelican Java to investigate the topics of Inheritance, Encapsulation and Polymorphism in Java.

Block C, Grade 12 Computer Science

IAs… Please make sure you make some additions to your Record of Tasks. Please make sure that your Criterion B is in your shared folder so I can have a look at it. Remember to use diagrams and pictures wisely so that you don’t eat into your wordcount.

IB2 Cover: Wednesday 26th August

Continue working on your IA

Remember:

  • Make at least two entries to your record of tasks.
  • Complete your first mock up of your application. You should show each screen.
  • Check the examples on student resources. If necessary, get one person to log in to the network and put them on a USB, and then pass the USB around.

Three ways round the “non-static method cannot be referenced from a static context” problem…

The problem occurs when you try to do this:

public class Dog {
  public static void main(String args[]){
    bark(); 
    // ERROR: non-static method cannot be referenced
    // from a static context
  }
  void bark() {
    System.out.println("Woof");
  }
}

Java is telling us that you cannot call bark() if you haven’t got a dog!

The solution is to instantiate a Dog before you call the bark() method, or… and this is the really lazy method… just declare your bark() method static, so that it doesn’t need an instance.

Solution 1: Two classes

public class DogMain {
  public static void main(String args[]){
    Dog d = new Dog();
    d.bark();
  }
}
class Dog {
  void bark() {
    System.out.println("Woof");
  }
}

Solution 2: Self-instantiating class

public class Dog {
  public static void main(String args[]){
    Dog d = new Dog();
    d.bark();
  }
  void bark() {
    System.out.println("Woof");
  }
}

Solution 3: Lazy cop-out

public class Dog {
  public static void main(String args[]){
    bark();
  }
  static void bark() {
    System.out.println("Woof");
  }
}

Java Resources

The best advice I can give an IB Computer Science student is to build their own examples.

  • An if statement
  • A while loop
  • A for loop
  • A try… catch block
  • Reading/writing text files
  • Summing an int array
  • Sequential search
  • Binary search
  • etc, etc, etc

Here are a few resources to help you:

The JAVA API (http://docs.oracle.com/javase/7/docs/api/)
This gives you details of every method of every class in the standard edition. Use the lefthand frame to scroll to the class you want. Check out the String class. It has over 50 methods that can make your life much easier!

The Java Tutorial (https://docs.oracle.com/javase/tutorial/java/index.html)
There are several trails in the official Java Tutorial. This is one of the most basic.

Blue Pelican Java (http://www.bluepelicanjava.com/)
Looks terrible but is one of the best ways you can learn the language. Download the PDF and read it offline. Do the first 20 chapters and you are ready for IB Comp Sci HL!

David Eck’s Course (http://math.hws.edu/eck/cs124/downloads/javanotes5-linked.pdf) is academic, but thorough.

Bruce Eckel’s Thinking in Java (http://www.saeedsh.com/resources/Thinking%20in%20Java%204th%20Ed.pdf) is a well-known free online textbook. A little old now but perfectly good for the IB course.

There are literally hundreds of courses on Youtube. You can even follow whole lecture series from MIT, Stanford, etc.

Princeton’s Elements of Programming (http://introcs.cs.princeton.edu/java/home/) is nice. I particularly like this cheatsheet that they have produced (http://introcs.cs.princeton.edu/java/11cheatsheet/)

The Java Language Specification (http://docs.oracle.com/javase/specs/jls/se8/html/index.html) is the last word on Java. Only use it if there is some really technical point that you need to find out about.

Data structures that a programmer should know

Beginner: Linked List, Stack, Queue, Binary Search Tree.
Intermediate: Heap, Priority Queue, Huffman Tree, Union Find, Tries, Hash Table, Tree Map.
Proficient: Segment Tree, Binary Indexed Tree, Suffix Array, Sparse Table, Lowest Common Ancestor, Range Tree.
Expert: Suffix Automaton, Suffix Tree, Heavy-Light Decomposition, Treap, Aho-Corasick, K-d tree, Link-Cut Tree, Splay Tree, Palindromic Tree, Rope,  Dancing Links, Radix Tree, Dynamic Suffix Array.

IB Computer Science 2 First-Day Handout, 2016 Exam

Letter to Parents

Welcome back for the final push. This summer we’ve had another excellent set of IB results with HL averaging 6.4 and SL averaging 6.0.

This year goes as follows:

  • Finish the taught syllabus: We have only one topic left to cover and it dovetails well with the IA, which is why I leave it until now. It will be done by the end of August.
  • Internal Assessment (IA): This is the key piece of project work. It is worth 20% to HL students and 30% to SL students. I will make the assessment criteria totally transparent, as always, and I will expect students to follow my guidelines assiduously. It is imperative that students meet their deadlines. Having to rush this work in January will almost certainly cost an IB grade.
  • Case Study: HL students have a case study element to their exam. This year it concerns computer animation. During the course of this year we will devote time to researching the issues surrounding computer animation so that we are well prepared for any question that could come up. However, the IB state clearly that they are looking for students to do their own research into case study material, and to incorporate it into their written exam answers.
  • Prepare for the exam: By the time we reach February I want students to have completed their IAs and finished all course notes. From then we will concentrate solely on reviewing course material and polishing our exam technique.

With respect to work load, the final year at school is among the most demanding of a person’s life. It is essential that students make the very best effort they can, all year long. They can relax come June 2016, but until then it’s got to be hard work all the way.

Best regards,

Justin Robertson
Computer Science
International School Manila

Application Development in Java: A Contact Manager

This is meant to give you an example of how to develop simple GUI applications in Java using Netbeans. It will be relevant to the Grade 10 Computer Programming course for the end-of-year project, and also the Internal Assessment of the IB Computer Science course both at higher level and standard level. You could use a similar model to produce all sorts of applications, like:

  • A library or catalogue of music, books, dvds
  • A customer or product database
  • An electronic photo album
  • A personal organizer or study planner
  • A quiz game

Points to note:

  • This is not meant to be a useful or interesting application! It only exists to show you some basic ways to build a user interface and store data on and retrieve data from the hard disk.
  • I try to separate the logic of the application from the interface as much as possible. Some classes are responsible for getting input from the user and displaying output. Other classes are responsible for adding, editing and deleting contacts — the core logic of the application. Separating the interface from the logic like this helps to build more reliable and easily maintained software.
  • I have added lots of comments to the source code so you can understand what is going on. A good idea is to follow the sequence of method calls for specific operations and button presses, for instance you could check exactly what happens when the Add Contact button is pressed.
  • The main input form is of type javax.swing.JFrame and the subform, used to add and edit contacts, is of type javax.swing.JDialog. In general I would always advocate using these two classes because it keeps your interface simple while still giving you enough scope for complexity.

 

ContactManagerGraphic