Search for notes by fellow students, in your own course and all over the country.

Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.

My Basket

You have nothing in your shopping cart yet.

Title: IB Computer Science HL Option D - OOP Notes
Description: Notes for IB Comp Sci Option D, including SL/HL..

Document Preview

Extracts from the notes are below, to see the PDF you'll receive please use the links above


Outline
Tuesday, 4 October 2016

6:44 PM

D—Object-oriented programming
D
...
2 Features of OOP (4 hours)
D
...
4 Advanced program development (15 hours)

OOP Page 1

General Notes
Thursday, 20 October 2016

10:00 AM

20/10/16
Package - group of classes
Java has libraries and packages (e
...
Swing which then contains a series of classes to do something)
Standardised version of Java design
MVC -> Model View Controller Package System Design Method
Model

View

Controller

Data
-> Underlying information which the
product uses
-> Class(es)
Create objects
• Attributes (Variables)
• Behaviours (Methods)

UI
-> User Interaction with product
-> Deals with displaying output &
accepting input

Backbone
-> The class(es) which do the work
-> Contains algorithms to deal with the user input &
output

Model says how to display

The actual display

Controller does calculation then sends to model

Java allows to store variables about a particular object and only allows a particular class to have access
Data is anything you can change, add to, remove, etc
...
dot notation (e
...
substring)
name
...
java -> addBooking()
Customers
...
java
CustomersForm
...

Controller
Application
...
java

The class which runs the rest of the product
...
main method)

View

Mainform
...
app
...
setvisible(true)
Open
...
secondform
...
setvisible(false) (this - current class)

26/10/16

...
getText()

...
setText("" + var);

27/10/16
D
...
variablename

1/11/16
D
...
2
Constructor method - exact same name as class (Customer)
Attributes of customer - age, name, (variables)
Making customer object
Customer Cus1 = new Customer();
Class Name, Object Name, Assignment, Reserved Word, Constructor Method (in order from L to R)
To get the age would use getAge()
To set the age would use setAge() (known as accessors and mutators)
Customers
|
Cus 1
Cus 2
Cus 3
Cus 4
Each customer has an age and name
In order to construct object a constructor is needed
To create multiple instances of same object - put it in a loop
Polymorphism

2/11/16
Customer
Name: JTextField
Gender: Jradio or JCombo
Date of Birth: 3JCombo
Email: J TextField
Re-Enter Email: J TextField
Phone No: JTextField
Address: JTextField
Username: JTextField
Password: JPassword
Re-enter Password: JPassword
Model

View

Controller

Customer RegisterForm Open
Application
Customer Class
String username
String password
String firstName
String lastName
String email
String gender
byte dobDay
byte dobMonth
short d
thenewboston

OOP Page 6

Organised General Notes
MVC -> Model View Controller Package System Design Method
Model

View

Controller

Data
-> Underlying
information
which the
product uses
-> Class(es)
Create
objects
• Attribut
es
(Variabl
es)
• Behavio
urs
(Metho
ds)

UI
-> User Interaction with
product
-> Deals with displaying
output & accepting input

Backbone
-> The class(es) which do the work
-> Contains algorithms to deal with the user input &
output

Model says
how to
display

The actual display

Controller does calculation then sends to model

Data is anything you can change, add to, remove, etc
...

Application
...
java

View

The class which runs the rest of the product
...


The first class which will run the product (contains the main
method)

Mainform
...
1 Objects as a programming concept
6:51 PM

Topic

Class Notes

Organised Notes

D
...
1 Outline the general nature • Objects
of an object
...

• A class that holds an object can be instantiated and does actions according to its attributes and behaviours
...
1
...


• A class is instantiated in order to create an object
...


• Instantiation - creating an instance
of a class that contains object
• LHS - Creating an instance of string
called name (object of type string)
• RHS - instantiates it and tells what
object it instatiates (instantiation)


• On the Left Hand Side, it is creating an instance of a string called 'name'
...


• An object is a location in memory
having a value and referenced by an
identifier
...

With the later introduction of
object-oriented programming the
same word, "object," refers to a
particular instance of a class
...
To instantiate is to create
such an instance by, for example,
defining one particular variation of
object within a class, giving it a
name, and locating it in some
physical place
From
...
com/D
...
2
+Distinguish+between+an+object+(definitio
n,+template+or+class)+and+instantiation>

D
...
3 Construct unified
modelling language (UML)
diagrams to represent object
designs
...
1
...

D
...
5 Describe the process of
decomposition into several
related objects
...
This reduces the complexity of the problem as it
makes it easier to deal with
...
1
...


Dependency – “uses a”
Aggregation – “has a”
Inheritance – “is a”

D
...
7 Outline the need to reduce
dependencies between objects
in a given problem
...
The first one depends on the second, since it cannot
function without it
...


D
...
8 Construct related objects
for a given problem
...
1
...

D
...
10 Describe how data items
can be passed to and from
actions as parameters
...

An argument is the value that is passed into a method, function or procedure
...
2 Features of OOP
Students should be able to describe the features of OOP that distinguish it from other approaches to computer programming
...
2
...


• Encapsulation is the hiding of the
internal details of a software
component
...


• Encapsulation is putting private variables and public methods together in a class
...

IB Question:
Outline how security can be enhanced by using encapsulation
...
2
...


• Inheritance - when a class is based • Inheritance is when a class is based on another class and inherits its data and actions
...

data and actions
...

• Extends - keyword creates a
subclass (is a relationship)
• e
...
Boss gets all the stuff an
Employee has
• Inheritance so we don't have to type
it again

D
...
3 Define the term
polymorphism
...

take on an instance of a number of • Polymorphism allows you to create a subclass of an existing class and redefine how a method works, so that
different (sub)classes
...

subclasses can have different
implementations of methods
...
2
...


• The fields of a class can be made
read-only or write-only
...

• The users of a class do not know
how the class stores its data
...

From
https://www
...
com/java/java_e
ncapsulation
...
This can limit errors and
side-effects of changes
...
2
...


D
...
6 Explain the advantages of
polymorphism
...

• More flexibile to change because
classes inherit from a common
superclass can be use
interchangeable
...


• A class can have total control over what is stored in variables and not have conflicting classes that conflict
the variables
• A class can change the data type of a field when parsing from one variable to another
...

Advantages of private variables
• Private variables only allows access to specific methods
...

• The variables can't be changed from other classes
...


D
...
3
...


• Class - a template for objects

• A class is a template for objects which defines the attributes and behaviours of objects within the
class
...

• An identifier is a name that refers to a variable, method, class, package
...
It can only be used
within a method
...


Anything called
...
)

• Without an object, class can't be
used
• Can have multiple objects in
class but cannot have the
same identifier
• Class is a template that outlines
things about an object and thing
that object can do

...

• Another logical error is dividing by 0
• Identifier
• Label for a variable, object, method,
class
• Anything that has a name that can
be referenced has an identifier
• Identifier are ways in which
something can be referenced (class,
object, variable, method, all need
identifiers)
• Need to be able to understand what
that thing is
• Primitive - the simplest form of data
(storing)
• 8 primitive data sizes with bit sizes
Boolean - 1 bit

Byte - 8 bit
Char - 16 bit or 7/8 bit (code in java
and have ability to have multiple
languages to code in)

Short - 16 bit (whole number)
Int - 32 bit
Float - 32 bit
Long - 64 bit
Double 64 bit

• Parameter variable - variable used
within a method's parameters
• Formal parameter - data type that is
expected within method signature
• Public void Customer (String name)
{ } Customer ("Hello");
• Parameter - data types and names
that are used within methods
D
...
2 Define the terms: method, • Method - behaviour of object
accessor, mutator, constructor, • Algorithm that is called upon an
signature, return value
...

• Constructor
• Accessor - method that retrieves a
variable's value (e
...
getAge())
• Mutator - sets the value (e
...
setAge())
• Signature
Method signature is method name
and formal parameters combined

• A method is an algorithm that is invoked on an object which causes an object to do something
• A constructor method is method that is invoked when creating a new instance of an object
...

• An accessor is a method that retrieves a variable's value
• A mutator is a method that sets a variable's value
• A signature is a method name and formal parameters combined
• A return value is a value that is returned after a method is called
• Validation is checking if two values match
• Verification is checking a value with another value that is already stored
Accessor:

• Return value
Value that is returned after a method
is called
Uses key word return

OOP Page 11

Mutator:

Mutator:

D
...
3 Define the terms: private,
protected, public, extends,
static
...
3
...


• Modifier: reserved word shown
before a method name
• Modifiers proceeds both variables
and methods
• Can be used for both variables and
methods
• Public, private, protected, static
• Public
-> Accessible anywhere in the
product
• Private
-> Accessible only in the class it has
been created in
• Protected
-> Only accessible within package it
has been created in
• Static
-> Cannot be changed
-> Doesn’t have to be instantiated
MainForm() mainform = new
mainform()
• Extends - key word that is used to
signify the class that is inheriting

• Public is when a variable or method is accessible anywhere in the product
• Private is when a variable or method is accessible only in the class it has been created in
• Protected is when a variable or method is only accessible within the package it has been created
in
...
It does not have to be instantiated
• Extends is a key word that is used to signify the class that something is inheriting

• (Byte) 8 Bits -> 28 -> 256 -> (-128 +
127)
• IB Question: Why do we use
unicode?

• ASCII is a character encoding scheme that represents English characters as numbers
...

• Unicode uses 16 bits and has code written in most of the languages of the world
...
[3 marks]
- Static means that the variable is declared once only;
- Static variable is a class variable not re-declared in each object;
- And not each time an object is created
- The variable represents the number of times an object is created;
- And hence is a total of what the object represents

• In IB Exam
ASCII and Unicode are two different formats used for representing characters
...
Outline the principal difference between ASCII and Unicode in representing characters
...
Discuss the social significance of providing Unicode instead of ASCII code for representing
characters in different software
...
3
...
3
...
3
...

D
...
6 Construct code examples
related to selection statements
...
3
...


Repetition (or reiteration) is implemented in code in the form of loops
...


D
...
8 Construct code examples
related to static arrays
...

• For example: integer array, string array
• Can also consist of objects

Characteristics of static arrays:
• Fixed length/size which is determined upon initialization of the array
• Size will not change during the execution of the program
• Memory allocated to array cannot be increased or reduced
• If more memory allocated than require
Title: IB Computer Science HL Option D - OOP Notes
Description: Notes for IB Comp Sci Option D, including SL/HL..