Showing posts with label ib. Show all posts
Showing posts with label ib. Show all posts

Tuesday, 24 January 2012

Computational Thinking




Computational Thinking is now a key element of the new IB arrangements.  Here are some sites which might help:
AGENTSHEETS
A computational science authoring tool
scalablegamedesign.cs.colorado.edu

Alice
Programming language based on Standard ML
www.ps.uni-sb.de/alice/

Beginer Developer Learning Center
from Microsoft ®
msdn.microsoft.com/vstudio/express/beginner/

Computer Science 4 Fun
www.cs4fn.org/

Computer Science -in -a-Box
Teach computational concepts without a computer
www.ncwit.org/unplugged

Computer Science Teachers Association
The primary resource for all CS teachers
csta.acm.org/

Computer Science Unpluged
csunplugged.com/

INTRODUCTION TO MEDIA COMPUTATION
A media-based path into computer science
coweb.cc.gatech.edu/mediaComp-plan

Phrogram
A programming environment for kids
phrogram.com/

Pre -Collegiate Faculty Connection
from Microsoft ®
www.microsoft.com/education/facultyconnection/
precollegiate

Scratch
Easy to learn programming for children
scratch.mit.edu/

The Integrated Circuit
http://nobelprize.org/educational_games/physics/

Monday, 23 January 2012

IB Computer Science - new arrangements documents

Change is inevitable...
IB Computer Science is changing next year (for first exam in 2014). 
Hopefully the move from Group 5 to Group 4 will have a positive impact on student uptake.  There are also quite a lot of dramatic changes with the compulsory OOP in Java element becoming one of four options.  The need for it to be Java has also been removed. 

We will probably stick with OOP as our elective and continue to use Java initially til we see what other schools are doing. 

Details of the changes can be found in these documents:

Computer Science Guide

Computer Science Subject Outline

There is also a good screencast on the OCC from the subject manager.

Friday, 20 January 2012

New IB course structure and content

Core Topics:
• Topic 1: System fundamentals (20 hours)
• Topic 2: Computer organization (6 hours)
• Topic 3: Networks (9 hours)
• Topic 4: Computational thinking, problem-solving and programming (45 hours)
HL extension
• Topic 5: Abstract data structures (23 hours)
• Topic 6: Resource management (8 hours)
• Topic 7: Control (14 hours)
Case studyAdditional subject content introduced by the annually issued case study
Option
(SL/HL core with aHL extension)
Option A: Databases
Option B: Modelling and simulation
Option C: Web science
Option D: Object-oriented programming (OOP)
Internal assessment
Practical application of skills through the development of a product and associated documentation
Group 4 project

(from August 2012, first examination 2014)

Tuesday, 17 January 2012

Inheritance



Just as children can inherit characteristics from their parents, subclasses can be created that inherit from superclasses.  The diagram above would need 4 classes (3 sub classes and 1 super class).  The 3 different types of bike would all have the same variables and methods as in the superclass and would also have variables or methods which are unique to this subclass.  The methods and variables are only defined once in the super class.  They are not redefined in the subclass. 

The advantages of inheritance are:

-efficiency : don't need to redefine procedures each time we create a new type of bike

-reliability : increased program structure

-reusability : code can be reused more easily making the program smaller and allowing it to execute faster

TASK 1:

TASK 2:
Create van, and car subclasses of the superclass vehicle. 
All vehicles will have a colour, cost and make as well as set and get methods. 
Van's will have a payload variable. 
Car's will have a doors variable.  (3 or 5 doors?)

TASK 3:
Test your classes from task 2 with a program that asks a user to create 1 car and 1 van and then displays their details. 

TASK 4:
Now extend the car class to create subclasses familycar, sportscar and vintagecar. 
Vintagecars have a yearbuilt variable. 
Sportscars have a topspeed variable. 
Familycars must have 5 doors. 

Test your new classes. 

Extension:
Try saving and loading car details to a file. 


Wednesday, 11 January 2012

RandomAccessFile (HL Mastery Factor)

Adding and deleting data from a RandomAccessFile requires the user to use the seek method to position the pointer at the correct point in the file. It is therefore not necessary to search though or load the entire file (i.e. sequentially) and access to the required data can be quicker.

First the programmer must import java.io.*;

Then the file needs to be created as an object
RandomAccessFile file = new RandomAccessFile("c:\\data\\file.txt", "rw");
The first argument is the filename and the second is the permission (read and write). 

I keep the data file in the same directory as my class files and declare the file name in a variable at the top for flexibility e.g.


public static RandomAccessFile file;
private static String fileName = "datafile.dat";

file = new RandomAccessFile (fileName, "rw");
file.setLength(3000);


Date can be read from the file using methods and assinged to variables if needbe:

int age = file.readInt();

There are also methods for readBoolean, readDouble, and so on. 

Most data is stored as a byte so the pointer will automatically move to the next item of information.  Strings are an exception as they might be of different lengths.  Therefore we need to set a designated size for each string and then move the pointer to a designated point. 

private final static int nameLength = 30;
String name1 = file.readUTF();
file.seek(nameLength); //move the pointer on to the next name
String name2 = file.readUTF();

Task 1
Compile, execute and then study the following code:

import java.io.File;
import java.io.RandomAccessFile;
import java.io.IOException;


public class RandomAccessFileExample {

    private static void doRAF() {

        try {
       
            File file = new File("RandomAccessFileExample.dat");
            RandomAccessFile raf = new RandomAccessFile(file, "rw");

            // Read a character
            char ch = raf.readChar();
            System.out.println("Read first character of file: " + ch);

            System.out.println("Read full line: " + raf.readLine());

            // Seek to the end of file
            raf.seek(file.length());

            // Append to the end of the file
            raf.write(7);
            raf.writeBytes("This will complete the example");

            raf.close();
           
        } catch (IOException e) {

            System.out.println("IOException:");
            e.printStackTrace();

        }
    }

    public static void main(String[] args) 

    {
        doRAF();
    }
}



Task 2
Write a program that asks for a password and then checks the password against what is contained in a file.  The program should keep asking the user for the password until the correct one is entered. 
Show your teacher the working program. 

Task 3
Amend your program from Task 2 so that when the correct password is entered the user is asked to change the password and this new password is then saved over the first one in the file.  Are there any issues if the new password is shorter?  Show your teacher your working program. 

Task 4
Using what you have learned, create a set of classes and implement them that allows for 2 or more different usernames and passwords.  Users should be able to add new users which are then saved to the datafiles.  Show your teacher the working program. 



       

Tuesday, 10 January 2012

Glossary


OK, I'm not sure a blog post is the best way to do a glossary. A-C already takes up quite a lot of space.

I'm going to create pages as tabs along the top and make the IB Java glossary one of these.

This will hopefully also provide a format to later organise links to posts of IB teaching content.

Monday, 9 January 2012

Java Glossary (A-C)

After going over student responses to a mock for IB paper 2, a colleague and I decided to create a Java programming glossary for our students.

A full version can be found out the Sun site (here) but there's too much in this that students don't need to know. Here is the start of my draft cut down version:

abstract
A Java programming language keyword used in a class definition to specify that a class is not to be instantiated, but rather inherited by other classes. An abstract class can have abstract methods that are not implemented in the abstract class, but in subclasses.

abstract class
A class that contains one or more abstract methods, and therefore can never be instantiated. Abstract classes are defined so that other classes can extend them and make them concrete by implementing the abstract methods.

abstract method
A method that has no implementation.
applet
A component that typically executes in a web browser, but can execute in a variety of other applications or devices that support the applet programming model.
argument
A data item specified in a method call. An argument can be a literal value, a variable, or an expression.

array
A collection of data items, all of the same type, in which each item's position is uniquely designated by an integer.

ASCII
American Standard Code for Information Interchange. A standard assignment of 7-bit numeric codes to characters. See also Unicode.
binary operator
An operator that has two arguments.

bit
The smallest unit of information in a computer, with a value of either 0 or 1.
boolean
Refers to an expression or variable that can have only a true or false value. The Java programming language provides the boolean type and the literal values true and false.
byte
A sequence of eight bits. The Java programming language provides a corresponding byte type.
case
A Java programming language keyword that defines a group of statements to begin executing if a value specified matches the value defined by a preceding "switch" keyword.


casting
Explicit conversion from one data type to another.

catch
A Java programming language keyword used to declare a block of statements to be executed in the event that a Java exception, or run time error, occurs in a preceding "try" block.


char
A Java programming language keyword used to declare a variable of type character.


class
In the Java programming language, a type that defines the implementation of a particular kind of object. A class definition defines instance and class variables and methods, as well as specifying the interfaces the class implements and the immediate superclass of the class. If the superclass is not explicitly specified, the superclass will implicitly be Object.

class method
A method that is invoked without reference to a particular object. Class methods affect the class as a whole, not a particular instance of the class. Also called a static method. See also instance method.

class variable
A data item associated with a particular class as a whole--not with particular instances of the class. Class variables are defined in class definitions. Also called a static field. See also instance variable.

classpath
A classpath is an environmental variable which tells the JavaTM virtual machine1 and Java technology-based applications (for example, the tools located in the JDK 1.1.X\bin directory) where to find the class libraries, including user-defined class libraries.
comment
In a program, explanatory text that is ignored by the compiler. In programs written in the Java programming language, comments are delimited using // or /*...*/.
compiler
A program to translate source code into code to be executed by a computer. The Java compiler translates source code written in the Java programming language into bytecode for the Java virtual machine1. See also interpreter.
constructor
A pseudo-method that creates an object. In the Java programming language, constructors are instance methods with the same name as their class. Constructors are invoked using the new keyword.

Monday, 2 January 2012

IB Computer Science HL Mastery Factors

Below is a list of the IB HL mastery factors. I intend to use the numbering from this list in my tagging to show what lesson covers which mastery factor(s).

Higher Level Mastery Skills:


To achieve a mastery factor of 1.0, you must have mastered at least 10 of the following 19 aspects:
  1. Adding data to an instance of the RandomAccessFile class by direct manipulation of the file pointer using the seek method.
  2. Deleting data from an instance of the RandomAccessFile class by direct manipulation of the file pointer using the seek method. (Data primitives or objects may be shuffled or marked as deleted by use of a flag field, therefore files may be ordered or unordered).
  3. Searching for specified data in a file.
  4. Recursion.
  5. Merging two or more sorted data structures
  6. Polymorphism.
  7. Inheritance.
  8. Encapsulation
  9. Parsing a text file or other data stream
  10. Implementing a hierarchical composite data structure.
  11. The use of any 5 standard level mastery factors (this can be applied only once
  12. Up to four aspects can be awarded for the implementation of abstract data types (ADT's).
  13. ADT 2
  14. ADT 3
  15. ADT 4
  16. Use of additional libraries (such as utilities and graphical libraries not included in syllabus appendix 2 Java Examination Tool Subsets).
  17. Inserting data into an ordered sequential file without reading the entire file into RAM.
  18. Deleting data from a sequential file without reading the entire file into RAM.
  19. Arrays of two or more dimensions.

Friday, 30 December 2011

IB Computer Science


One of my main intentions of this blog is to share my work, thoughts and resources for teaching IB Computer Science, and in particular the Java programming element.

I currently have a Higher Level set but not a Standard Level so the order of material will tend to be what I'm currently teaching and not the whole 2 year course from start to finish. Hopefully the use of tags will mean it does coalesce into a meaningful resource.