Welcome to Programming Foundations FIT9131
FIT9131 Week 1
1
Welcome to
Programming Foundations
FIT9131
Week 1: Introduction
FIT9131 Week 1
2
Unit Lecturers
Wed 2-4 pm in K309 AND Wed 6-8 pm in K309
Mark Creado
Tel: 9903 1249
Room: H7.13 Caulfield Campus
mark.creado@monash.edu
Wed 2-4pm in E224
Jian Liew
jian.liew@monash.edu
mailto:mark.creado@monash.edu
FIT9131 Week 1
3
Lecture 1 outline
• Introduction and expectations
• What is a computer?
• What is a computer program?
• Programming languages
• Program translation
• Introduction to Java and BlueJ
• Introduction to object-oriented programming
FIT9131 Week 1
4
Aim and Learning Outcomes
The aim of FIT9131 is to provide you with a sound
foundation in the basic design and development
of reliable, maintainable and reusable programs.
On successful completion of this unit, students
should be able to:
1. design, construct, test and document small
computer programs using Java;
2. interpret and demonstrate software engineering
principles of maintainability, readability, and
modularisation;
3. explain and apply the concepts of the “object-
oriented” style of programming.
FIT9131 Week 1
5
Please keep in mind …
At the completion of this unit, you will NOT
become:
•an expert programmer
•an expert Java programmer
•an expert in object-oriented programming
• to achieve these levels of expertise you need to do
more advanced programming units.
FIT9131 Week 1
6
Lectures
Copies of the lecture slides will be made available on the
FIT9131 Moodle site. Download and study them before
attending the lectures.
During the lecture:
• LISTEN to what is said.
• THINK about what is said.
• ASK questions when you do not
understand.
• WRITE down what is important.
• DO NOT TALK amongst yourselves unless you are
invited to do so.
• TURN OFF YOUR MOBILE PHONE (or to silent mode)
FIT9131 Week 1
7
Lecture Sessions
• for each week, there are 3 repeat lecture sessions
• the materials presented for the 3 lectures are
identical – there is no need to attend more than one
lecture each week
• you should be enrolled in ONE of the lectures (and
attend that lecture only)
• If possible you must attend a tutorial class after
your allocated lecture.
FIT9131 Week 1
8
Tutorial/Lab classes
z held in computer laboratories for two hours per week
z group of approximately 18-20 students, plus a tutor
z in these classes you will put into practice the concepts and
techniques learnt in lectures
z there is typically also some home work to be completed
outside the tutorial classes.
z interactive — participation encouraged
z attendance at tutorial classes will be recorded.
FIT9131 Week 1
9
Off-Campus Learning (OCL)
If you are an OCL student :
z download and study the online lecture recordings
every week
z check the FIT9131 Moodle site regularly
z do the weekly lab exercises every week on schedule
z do the weekly homework every week on schedule
z participate in the FIT9131 discussions forums for
OCL students
z seek help from teaching staff as needed (via emails
or forums)
FIT9131 Week 1
10
Assignments (15%+25%)
You must :
z start working on your assignments as soon as the
specifications are available
z show your work to your tutor regularly
z be able to able to explain and modify your code
during assessments (via individual interviews)
z stick to the submission deadlines (there will be no
extensions)
z seek help from teaching Staff as needed via:
zHelp Desk, email, tutorial classes (On-campus
students)
z forum, email (OCL students)
FIT9131 Week 1
11
Unit Tests
Please ensure to read the unit guide regarding the unit
test in the week of the assignment submission.
Assignment structures have been changed from
previous offerings.
Unit tests are hurdles to the overall assignment
submission for both assignments in this unit.
FIT9131 Week 1
12
Online quizzes
There are online quizzes available for you to test your
own understanding of the concepts learnt
throughout the semester
You are supposed to complete them within the
allocated time period (typically 1-1.5 weeks)
They are not officially graded, but completing them
(by yourself) will greatly help your understanding of
the materials in this unit
FIT9131 Week 1
13
Resources
z Software – Java and BlueJ
z Hardware
z Moodle site accessible through My.Monash portal
http://my.monash.edu.au/
z Unit Information Guide – available from unit’s Moodle site
z Library
z Other FIT9131 students
z FIT9131 helpdesk (starting in Week 3)
z Staff
http://my.monash.edu.au/
FIT9131 Week 1
14
Textbook
Important :
You are expected to
purchase a copy of this
textbook.
All the weekly exercises will
contain references to the
book (both theory & actual
exercises). Bring the book to
each tutorial class.
FIT9131 Week 1
15
Assessment
Assessment for this unit will comprise:
• Two assignments (total 40%) due week 7 (Assignment 1, 15%)
and week 12 (Assignment 2, 25%). This includes a unit test
worth 5% of the total mark for each assignment.
• A final exam (60% ) held during the examination period.
To pass the unit you must comply with the Faculty “40%-rule“
and obtain:
• 40% or more in the unit’s examination and
• 40% or more in the unit’s non-examination assessment and
• an overall unit mark of 50% or more.
FIT9131 Week 1
16
Marks and Grades
Final mark Grade
80-100 High Distinction (HD)
70-79 Distinction (D)
60-69 Credit (C)
50-59 Pass (P)
< 50 Fail (N)
FIT9131 Week 1
17
A typical semester’s results?
FIT9131 Week 1
18
Common Causes of Failing
For on-campus students :
• Not attending classes – this is the number 1 cause
• Not completing the weekly exercises (lab +
homework) on time
•as a rule, falling behind more than 2 weeks is
not acceptable, as the weekly materials are
almost always dependent on previous weeks’
work
•not seeking help early enough
• Plagiarism and Cheating
FIT9131 Week 1
19
Common Causes of Failing
For off-campus (OCL) students :
• Not completing the weekly exercises (lab +
homework) on time
•as a rule, falling behind more than 2 weeks is
not acceptable, as the weekly materials are
almost always dependent on previous weeks
•not seeking help early enough
•you must be very disciplined when doing this
unit in OCL mode
• Not participating in the online discussion forums
• Plagiarism and Cheating
FIT9131 Week 1
20
Plagiarism and Cheating
• Monash University takes plagiarism and cheating
very seriously and these incur severe penalties.
• Plagiarism is using someone else's work, but not
acknowledging it. Cheating is pretending that
someone else's work is your own, in order to gain
an unfair advantage.
• It is OK to help each other with the assignment
work, BUT each person must write the entire
assignment alone and be able to explain and
modify it on request.
FIT9131 Week 1
21
Workload Management and
Expectations
FIT9131 Week 1
22
Workload Management and
Expectations
z from the FIT9131 Unit Guide:
Minimum total expected workload equals 12 hours per week comprising:
(a.) Contact hours for on-campus students:
2 hours of lectures
One 2-hour laboratory
(b.) Study schedule for off-campus students:
Off-campus students generally do not attend lecture and tutorial sessi
ons, however should plan to spend equivalent time working through t
he relevant resources and participating in discussion groups each wee
k.
(c.) Additional requirements (all students):
A minimum of 8 hours independent study per week for completing la
b and project work, private study and revision.
FIT9131 Week 1
23
What is a computer?
Early ‘computers’ were humans.
The term ‘computing machine’ was used increasingly from the 1920s for
machines that did the work of a human computer
FIT9131 Week 1
24
What did early computers look
like?
A reconstruction of the Manchester Baby
One of the earliest stored-
program computer :
Manchester ‘Baby’ (first
ran on 21 June 1948)
FIT9131 Week 1
25
Monash’s First Computer :
The Ferranti Sirius, 1962
FIT9131 Week 1
26
A modern Supercomputer
Sunway TaihuLight
World’s Fastest SuperComputer
(June 2016)
FIT9131 Week 1
27
What is a computer?
FIT9131 Week 1
28
Computer systems
A computer system has these components:
•Hardware
•Software
•Procedures
•Data
•People
• Hardware is the machine itself.
• Software tells the hardware what to do.
• Procedures tell people how to use the system.
A computer processes data and produces information
useful to people.
FIT9131 Week 1
29
Hardware
input
device
output
device
secondary
storage
device
central
processing
unit (cpu)
main
memory
INPUT
???
OUTPUT
???
STORAGE
???
FIT9131 Week 1
30
Hardware
input
device
output
device
secondary
storage
device
central
processing
unit (cpu)
main
memory
INPUT
keyboard, mouse,
joystick, bar code
reader, scanner,
paper tape, cards…
OUTPUT
screen, printer, plotter,
speech synthesizer,
paper tape...
STORAGE
magnetic disk, CD-
ROM, USB flash
disk, tape, ...
FIT9131 Week 1
31
Hardware
input
device
output
device
secondary
storage
device
central
processing
unit (cpu)
1001011110101
0111010001110
1101001011001
Program(s), in binary code
FIT9131 Week 1
32
Two broad classifications:
System software — computer programs to control
the computer and provide a user interface (e.g.
operating system, windowing system, file
management software)
Application software — computer programs to
perform specific tasks (e.g. word processor,
database management system, web browser, your
programs)
Software
FIT9131 Week 1
33
What is a computer program?
• a set of instructions to be obeyed (or executed)
in order to solve a problem
• typically data plus processing
• purpose is to convert data into information
• particularly useful for large amounts of data
and complicated processing
Data
Program
OutputComputer
FIT9131 Week 1
34
History of programming
languages
MACHINE CODE
ASSEMBLER LANGUAGES
HIGH-LEVEL
LANGUAGES
4GLs
5GLs
FORTRAN, COBOL, C,
LISP, Pascal, C++,
C#, Java ...
ORACLE, SEQUEL, INGRES, ...
artificial intelligence
FIT9131 Week 1
35
Language history
FORTRAN I
FORTRAN II
ALGOL 60
LISP
ALGOL 58
CPL
COBOL
COMTRAN
FLOW-MATIC
PROLOG
ADA
PASCAL
SIMULA 67
SIMULA I
PL/1
BASIC
FORTRAN IV
B
BCPL
ALGOL 68
SMALLTALK 80
EIFFEL
C++
C
BETA
JAVA
1950
1960
1965
1970
1975
1980
1985
1990
1995
MODULA 2
MODULA 3OBERON
C# 2000BlueJ (not a language!)
FIT9131 Week 1
36
Different programming languages
Machine code Assembler
• 000 100C LDA VALUE
• 006 300D ADA TOTAL
• 007 200D STA TOTAL
• 100 DW1 TOTAL
• 110 DW1 VALUE
COBOL
FORTRAN
LISP
Pascal
Java
ADD VALUE TO TOTAL
TOTAL = TOTAL + VALUE
(set! total (+ total value))
total := total + value
total += value;
Low-level
High-level
FIT9131 Week 1
37
Program translation
• a program written in a high-level language
(such as Java) must be translated into machine
code before the computer can run it (i.e. execute
the instructions). This is because a computer
can really only understand machine code.
• the translation is typically done by a process
called a compilation. There is another similar
process called interpretation which is also used
to translate a program.
FIT9131 Week 1
38
Compiler vs. interpreter
The main difference between a compiler and an
interpreter :
•a compiler attempts to translate an entire
program at once, and gives a list of the problems
it found (if any) in the end. This is usually a
batch process.
•an interpreter, on the other hand, translates one
instruction at a time and causes that instruction
to be executed immediately. This is usually an
interactive process.
FIT9131 Week 1
39
Program translation
Source code
written in
high-level
language
(eg. Pascal,
C++, Java)
Executable
code in
binary
(10110…..)
Language
translators
(compilers,
interpreters)
FIT9131 Week 1
40
Java program translation
Program translation in Java involves two phases:
1. Java source code is (typically) compiled to
something called bytecodes.
2. The bytecodes are then interpreted to machine
code by a Java Virtual Machine (JVM).
The Java Virtual Machine is just a piece of software.
Each type of machine (e.g. PC, Mac) has its own
Java Virtual Machine to convert bytecode to the
native machine code.
FIT9131 Week 1
41
Java program translation
Source code
written in
Java
Executable
code in
binary
(10110…..)
Java
compiler
Java
bytecode
(21416….)
Java
interpreter
(Java Virtual
Machine)
“machine-neutral”
“machine-dependent”
FIT9131 Week 1
42
Java : write once, run anywhere!
• Java programs are able to run on any kind of
computer when downloaded from the Web.
• With most languages, that would mean
downloading source code for the program and
having a compiler translate it into the machine
code for your machine. The user would have
to tell the machine to compile the source code
before running the program.
• Java uses bytecodes to solve this problem.
FIT9131 Week 1
43
Executing a Java program
Editor Javacompiler
Java
interpreter
JVM
Bytecode
Verifier copy of
bytecodes
bytecodes
bytecodes
Java source
code
(Maybe)
On
remote
computer?
On local
computer
FIT9131 Week 1
44
A computer program (in Java)
public class InterestCalculator
{
private int interestRate;
private int balance;
private int interest;
public InterestCalculator()
{
interestRate = 5;
balance = 1000;
}
public void calculateInterest()
{
interest = balance * interestRate / 100;
}
}
FIT9131 Week 1
45
Java and BlueJ
In FIT9131 this semester we will learn Java using the BlueJ
development environment. BlueJ was designed for teaching
introductory object-oriented programming in Java. It provides:
• a full Java development environment
• visualisation of classes and objects
• an editor
• an inspector
• a debugger
Both Java and BlueJ are free. You will be given instructions about
how to use them in the computer labs and at home.
FIT9131 Week 1
46
Programming paradigms
There are several different styles of writing computer
programs. These are called “paradigms”. Some
common paradigms are: procedural, functional,
logic, object-oriented, and event-driven. Different
languages typically use different paradigms, to
solve different kinds of problems. Some
programming languages can use more than one
paradigm.
Java uses the object-oriented paradigm. This means
that the basic building blocks of a program in Java
are objects and classes.
FIT9131 Week 1
47
Object-oriented programs
The object-oriented (OO) programming paradigm
uses objects to model a situation. A program
can be written in a non-object-oriented way, but
the object-oriented style is increasingly popular
for three main reasons:
•programs are becoming more and more
complex, and the OO style handles this best
• the OO style makes it easy to re-use existing
programs or parts of programs
• the OO style makes programs much easier to
maintain
FIT9131 Week 1
48
Objects
We are all familiar with the idea of an object in
everyday life. We are surrounded by them: cars,
books, people, houses, cats, etc.
Objects have attributes, e.g. colour, size, age, name.
Objects also have behaviour. They can do things,
e.g. grow, breathe, run, stop.
http://www.webweaver.nu/clipart/img/nature/cats/cat2.gif
FIT9131 Week 1
49
Attributes and Behaviour
Car
Cat
Attributes Behaviour
Registration number
Manufacturer
Model
Year
Colour
Start
Stop
Turn
Accelerate
Name
Breed
Colour
Age
Weight
Registration number
Sleep
Eat
Purr
Climb
Scratch
Eg :
FIT9131 Week 1
50
Classification
We can classify objects into groups according to their
common attributes and behaviour.
Let's say we want to classify objects into cats and non-
cats. What are the common attributes and
behaviour of something we would classify as a cat?
How would you recognise a cat if you saw one?
http://www.pictures-of-cats.org/images/british-shorthair-header.jpg
http://images.google.com/imgres?imgurl=http://www.pictures-of-cats.org/images/snowshoe-3.jpg&imgrefurl=http://www.pictures-of-cats.org/snowshoe-cat.html&h=576&w=384&sz=35&hl=en&start=58&um=1&tbnid=aCOeGPqWMlI__M:&tbnh=134&tbnw=89&prev=/images%3Fq%3D%2Bsite:www.pictures-of-cats.org%2Bcat%2Bbreeds%26start%3D40%26ndsp%3D20%26um%3D1%26hl%3Den%26sa%3DN
http://images.google.com/imgres?imgurl=http://www.pictures-of-cats.org/images/Grey-dwarf-persian-kitten.jpg&imgrefurl=http://www.pictures-of-cats.org/dwarf-cats-and-miniature-cats.html&h=193&w=200&sz=34&hl=en&start=82&um=1&tbnid=wE5V2DiWupYWlM:&tbnh=100&tbnw=104&prev=/images%3Fq%3D%2Bsite:www.pictures-of-cats.org%2Bcat%2Bbreeds%26start%3D80%26ndsp%3D20%26um%3D1%26hl%3Den%26sa%3DN
http://images.google.com/imgres?imgurl=http://www.pictures-of-cats.org/images/bengal-cat-n1.jpg&imgrefurl=http://www.pictures-of-cats.org/bengal-cats-for-sale.html&h=243&w=154&sz=19&hl=en&start=99&um=1&tbnid=yL25IaQIo4p3HM:&tbnh=110&tbnw=70&prev=/images%3Fq%3D%2Bsite:www.pictures-of-cats.org%2Bcat%2Bbreeds%26start%3D80%26ndsp%3D20%26um%3D1%26hl%3Den%26sa%3DN
http://images.google.com/imgres?imgurl=http://www.itswild.org/files/images/Lion.jpg&imgrefurl=http://www.itswild.org/image/tid/35&h=480&w=395&sz=47&hl=en&start=27&um=1&tbnid=hSnfjH_57gvKVM:&tbnh=129&tbnw=106&prev=/images%3Fq%3Dlion%26start%3D20%26ndsp%3D20%26um%3D1%26hl%3Den%26sa%3DN
http://images.google.com/imgres?imgurl=http://www.palmbeachpost.com/shared-blogs/palmbeach/cerabino/camel.jpg&imgrefurl=http://www.palmbeachpost.com/blogs/content/shared-blogs/palmbeach/cerabino/&h=291&w=300&sz=20&hl=en&start=3&um=1&tbnid=70N3hkECN-rvLM:&tbnh=113&tbnw=116&prev=/images%3Fq%3Dcamel%26um%3D1%26hl%3Den%26sa%3DG
http://images.google.com/imgres?imgurl=http://www.iacuc.arizona.edu/training/cats/images/Tabby1-DomesticCat-Closeup.jpg&imgrefurl=http://www.iacuc.arizona.edu/training/cats/index.html&h=746&w=787&sz=95&hl=en&start=19&um=1&tbnid=0gJ8heloXzEZ3M:&tbnh=136&tbnw=143&prev=/images%3Fq%3Dcats%26ndsp%3D20%26um%3D1%26hl%3Den%26sa%3DN
http://images.google.com/imgres?imgurl=http://www.catsofaustralia.com/persian_breeders_files/Seal%2520Pt%2520Male.JPG&imgrefurl=http://www.catsofaustralia.com/HimalayanCat.htm&h=480&w=432&sz=26&hl=en&start=138&um=1&tbnid=_Y4NsIhyOQNATM:&tbnh=129&tbnw=116&prev=/images%3Fq%3Dcats%2Bbreeds%26start%3D120%26ndsp%3D20%26um%3D1%26hl%3Den%26sa%3DN
http://images.google.com/imgres?imgurl=http://www.egyptianmaubreed.com/public/about/1.jpg&imgrefurl=http://www.egyptianmaubreed.com/public/index.php%3Fpage%3Dabout&h=258&w=409&sz=20&hl=en&start=130&um=1&tbnid=ldOAOdCu34gbzM:&tbnh=79&tbnw=125&prev=/images%3Fq%3Dcats%2Bbreeds%26start%3D120%26ndsp%3D20%26um%3D1%26hl%3Den%26sa%3DN
FIT9131 Week 1
51
Classes
In a computer program, we use classes to describe a
group of similar objects. A class is a description
of what an object would look like if we had one.
It is based on common attributes and behaviour of
objects.
Cat
name
breed
colour
age
weight
registration number
A Class Diagram
sleep
eat
purr
climb
scratch
Class Name
Attributes
Behaviour
FIT9131 Week 1
52
Instances of classes
A class is a template or pattern from which many
objects can be created. It is a description of an
object.
Each object created from a class is called an instance
or an object of that class. This process is called
instantiation.
We can have multiple instances (objects) of the same
class. Each object has the same attributes and the
same behaviour. However, the values of the
attributes might be different.
FIT9131 Week 1
53
State of an object
The state of a particular object is the values of its
attributes at any particular moment. For example, a
cat might have the following state:
Name: Stimpy
Breed: Burmese
Colour: Lilac
Age: 11 years, 4 months, 8 days
Weight: 3.6 kg
Registration number: 213
Some of these attributes change constantly. Others
stay the same for long periods, or forever.
FIT9131 Week 1
54
Identity of an object
We can have several different objects that have
the same attributes and behaviour (ie. the same
state) but are still different objects.
An object has identity. We can give it a name to
distinguish it from the others (e.g. ball1, ball2).
FIT9131 Week 1
55
Making something happen
If you have an existing class, in order to make
something happen, you need to:
1. Create an object of that class.
2. Ask that object to do something that it knows
how to.
You will experiment with doing this in BlueJ
during the tutorial sessions.