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 dobYear
String phone
String address
Question on exam to construct MVC
constructor method - method that is called when creating a new instance
public class Customer {
variables (private)
public Customer (String username, String password, String firstName…)
this
...
password = password;

OOP Page 3

Formal parameters are required to be in particular
orders (in same order as GUI and written)

public setUsername (String Username) {
this
...
username = username;
}
public String getUsername() {
return username;
}

this
...
toString()
ArrayList

8/11/16
Array - static (fixed length)
ArrayList - dynamic (no length)
Serial - A stream of data
Serialisation
Import first, then serialise/deserialise

9/11/16
Literal String - double quotations
Use it when you want words, sentences, parts of sentences
Whole group of methods for strings because its an object
Initialising - variables
Instantiation - Objects
Invoking - Methods
Model -> Customer data (Customer class)
Inside customer class, created private variables
Controller contains two classes
Open contains main method and creates instance of application
Application -> created forms we needed
Array contains indices - can say customer ID is a certain number
CustomerForm
Find
Input int
Pass to Application -> findCust
-> customerList
...
g
...
getFirstname();
Then setText() to CustomerForm

10/11/16
For loop each time check to see if username and password are the same and logged in as
Validation & Verification
Validation - checking if 2 values match
Verification - checking a value with a value that is already stored
Question ON EXAM

28/02/17
Simple
Self-explanatory
Specific
On the board:
Structured
Efficient
Fast
Useful

OOP Page 4

Useful
Competent
Consistent
Resourceful
Concise
Predictable
Understandable
Mr Madigan:
Code should be robust (tough or hard to break)
(e
...
if you put in wrong values it doesn't break)
Code must deal with unexpected inputs
Code should be adaptable
Changeable
Code must be able to change overtime to meet changing needs
Related: portable
Code should be reusable
The same code is usable in different contexts
OOP achieves these things through:
Encapsulation
Class WaitingRoom {
Patient[] waitinglist;
}

Class Patient {
private int priority;
private int arrivalTime;
}
private void reorder() {
waitinglist[i]
...
getPriority;
}
public int getPriority() {
return this
...

There are two methods in the boss object
...
That is, the characters of
output string alternate between the two input strings
...


3/10/17
Task: Write a method in java which takes a linked list as a parameter and returns a linked list which is the reverse

14/11/17
C is a collection containing (in order):
1, 17, 42, 3, 9, 16, 6, 8, 11
What is the output of the algorithm?
17
42
9
16
8
11

OOP Page 5

Write a method in your java LinkedList class which:
has a precondition that the Linked List is SORTED
...

(In other words, your post-conditions is that 'data' is in the list, and the list is still sorted
...


Create an instance of class or object - instantiation
String name = new String
LHS - Creating an instance of string called name (object of type string)
RHS - instantiates it and tells what object it instantiates (instantiation)

Delegate package
...
java

Open
...
Contains all algorithms to run
the product and to open the GUI
...
java
The first GUI form which
opens in the product

If it contains main method, it is static (therefore class is static)
Create instance of static class called application
Application will contain everything else

OOP Page 7

D
...
1
...

• Class is template of objects

• An object is an abstract entity that contains attributes (variables) and behaviours (methods)
...


D
...
2 Distinguish between an
object (definition, template or
class) and instantiation
...
The object can then be run anywhere in the program
...

• On the Right Hand Side, it instantiates the object and tells the program what object to instantiate
...
An object can be a
variable, function, or data structure
...

• Instantiation is the creation of a real
instance or particular realization of
an abstraction or template such as a
class of objects or a computer
process
...
wikispaces
...
1
...
1
...


• You need class
• Attributes
• And Actions/Methods
• Has a/ is a/ uses


How to make UML diagrams:

Class Name
-variablename: variable type
-partners: ArrayList
+methodname (parsename: variabletype): returntype
+Airline (data : String[]) : void
- private
+ public

D
...
4 Interpret UML diagrams
...
1
...


An object can be decomposed into a bunch of smaller objects
...


D
...
6 Describe the relationships
between objects for a given
problem
...
1
...


Dependencies occur when one object uses another object
...

This can increase maintenance for the programmer because if one object updates, then they will have to
update the other objects that interdepend on the object
...
1
...

D
...
9 Explain the need for
different data types to represent
data items
...
1
...


A parameter is the name of the information that is used in a method, function or procedure
...


OOP Page 8

D
...

Topic

Class Notes

Organised Notes

D
...
1 Define the term
encapsulation
...
The scope of data
should be confined to the object
which stores that data
...
The variables can only be
accessed from other classes by using the get and set methods
...


D
...
2 Define the term
inheritance
...
The subclass extends the
on another class it can inherit its
superclass
...
We say that the
• Extends is a keyword that creates a subclass
subclass extends the superclass
...
g
...
2
...


• A variable is polymorphic if it can
• Polymorphism is the ability to create a variable, a function, or an object that has more than one form
...
The different
when the method is called by other code (or even the super class's code) your method is executed instead
...

• Doesn't need to worry about if…

D
...
4 Explain the advantages of
encapsulation
...

• A class can have total control over
what is stored in its fields
...
A class
can change the data type of a field
and users of the class do not need
to change any of their code
...
tutorialspoint
...
htm

• Advantages of private variables:
Only allows access to methods
that access it (other classes
don't have access)
The variables can't be
changed from other classes
• Encapsulation limits dependencies
in code
...

D
...
5 Explain the advantages of
inheritance
...
2
...


• Key benefit inheritance minimize
the amount of dupe code in
application sharing common codee
amongst several subclasses
...

• Reusability
• Inheritance allows for similar classes
to reuse the same methods without
retyping the same code
...
The code in the class
does not have to be changed
...
Other classes that may conflict with it can't access
it
...


Advantages of inheritance
• Inheritance minimizes the amount of duplicate code by sharing the same code with several subclasses
• Inheritance makes the code more flexible because multiple classes can inherit from a common superclass
and the code can be used wherever
...


• Polymorphism allows external code Advantages of polymorphism:
- Polymorphism allows external code to call the methods of the superclass without needing to know the
to call the methods of the
superclass without needing to know
implementation details of a method
- Allows methods that perform similar or closely related functions to be accessed through a common name
the implementation details of the
method
...
2
...

objects
• Saves time by copy/pasting already
made code to the program
• Restricts certain methods and
actions if you're not using them
• Examples of java libraries
Java
...
lang
...
math
Java
...
awt
Many more…

D
...
8 Describe the
disadvantages of OOP

Advantages of encapsulation
• The variables of a class can be made read-only or write-only

• It can be difficult to initially
comprehend concepts such as
inheritance and polymorphism
• It can be difficult and unnecessary

OOP Page 9

Advantages of libraries of objects
• Using libraries provide an easy method of reusing objects
...

IB Question:
Explain why it is convenient to store data as objects
...
g
...

- It can be difficult and unnecessary to use objects to solve particular problems
- For some problems, the amount of code necessary is much larger with OOP
...
See toy example to compare
Java and Python
...

- Risk of object dependencies

D
...
9 Discuss the use of
programming teams
...
Everyone needs to know exactly what their
development of narrow
narrow expertise
methods/classes must do and how they interact with other
expertise
- It works well with object oriented
classes and methods
...
Everyone
needs to know exactly what
their methods/classes must
do and how they must
interact with other classes and
methods
...
2
...


https://www
...
com/techno
logy/blog/4-benefits-of-objectoriented-programming
• Modularity - breaking something
down to bits
• Easier debugging because each
small part can be debugged and
perfected separately
...

• Independent testing!
• Allows the same code to be reused
many times without retyping it
• Several programmers can be
working on separate
modules/methods/classes at the
same time
Explain why modularity allows
____ and why it's a good thing

OOP Page 10

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