FIT9131 Week 1
Welcome to Programming Foundations FIT9131
1
Week 1: Introduction
FIT9131 Week 1
Unit Lecturers
Mon 1-3pm in C1 Clayton
Judy Sheard
Tel: 9903 2701
Room: H6.46 Caulfield Campus judy.sheard@monash.edu
In Malaysia:
Ong Huey Fang ong.hueyfang@monash.edu
2
FIT9131 Week 1
Lecture 1 outline
3
• 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
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.
4
FIT9131 Week 1
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.
5
FIT9131 Week 1
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) 6
FIT9131 Week 1
Lectures
• One 2 hour lecture is scheduled each week.
• The Week 1 lecture will be available online
• The lecture is scheduled before the tutorial classes for that week.
• It is important to attend the lecture before the tutorial as the tutorial will build on what is covered in the lecture.
7
FIT9131 Week 1
Tutorial classes
8
⚫ held in a collaborative studio environment for two hours each week
⚫ groups of up to 60 students with 4 tutors
⚫ in these classes you will put into practice the
concepts and techniques learnt in lectures
⚫ Typically, also some home work to be completed outside the tutorial classes.
⚫ From week 3 there will be pre-tutorial tasks assessed at the beginning of each tutorial
⚫ interactive — participation encouraged
⚫ attendance at tutorial classes will be recorded.
FIT9131 Week 1
Flexible (Online) Learning
If you are enrolled as an online student :
⚫ download and study the lecture recordings every week
⚫ check the FIT9131 Moodle site regularly
⚫ complete the weekly tutorial exercises every week
⚫ complete the weekly homework every week and
⚫ participate in the FIT9131 discussions forums for online students
⚫ seek help from teaching staff as needed (via zoom sessions, forums or emails)
9
FIT9131 Week 1
Assignments (10% and 25%)
You must :
⚫ start working on your assignments as soon as the specifications are available
⚫ show your work to your tutor regularly
⚫ be able to explain and modify your code during
assessments (via individual interviews)
⚫ stick to the submission deadlines (there will be no
extensions)
⚫ seek help from teaching Staff as needed via:
⚫Help Desk, email, tutorial classes (On-campus students)
⚫forum, email (Online students) 10
FIT9131 Week 1
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
11
FIT9131 Week 1
Resources
⚫ Software – Java and BlueJ
⚫ Hardware
⚫ Moodle site accessible through My.Monash portal http://my.monash.edu.au/
⚫ Unit Information Guide – available from unit’s Moodle site
⚫ Library
⚫ Other FIT9131 students
⚫ FIT9131 helpdesk (starting in Week 3)
⚫ Staff
12
FIT9131 Week 1
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.
13
FIT9131 Week 1
Assessment
Assessment for this unit will comprise:
• Two assignments: due week 7 (Assignment 1, 10%) and week 12 (Assignment 2, 25%)
• Pre-tutorial tasks: (5%)
• A final exam (60%) held during the examination
period.
To pass the unit you must comply with the Faculty
“45%-rule“ and obtain:
• 45% or more in the unit’s examination and
• 45% or more in the unit’s non-examination assessment and
• an overall unit mark of 50% or more. 14
FIT9131 Week 1
Marks and Grades
15
Final mark
80-100 70-79 60-69 50-59
< 50
Grade
High Distinction (HD) Distinction (D) Credit (C) Pass (P) Fail (N)
FIT9131 Week 1
A typical semester’s results?
16
FIT9131 Week 1
17
Common Causes of Failing
For On-campus students :
• Not attending classes – this is the number 1 cause • Not completing the weekly exercises (lab +
• 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
homework) on time
FIT9131 Week 1
18
Common Causes of Failing
For Online students :
• Not reviewing the lecture
• Not completing the weekly exercises 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
• Not participating in the online discussion forums • Plagiarism and Cheating
unit in OCL mode
FIT9131 Week 1
Plagiarism and Cheating
19
• 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
Workload Management and Expectations
20
FIT9131 Week 1
Workload Management and Expectations
⚫ 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 sessions; however should plan to spend equivalent time working through the relevant resources and participating in discussion groups each week.
(c.) Additional requirements (all students):
A minimum of 8 hours independent study per week for completing
lab and project work, private study and revision.
21
FIT9131 Week 1
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
22
FIT9131 Week 1
What did early computers look like?
One of the earliest stored- program computer : Manchester ‘Baby’ (first ran on 21 June 1948)
23
A reconstruction of the world’s first computer
FIT9131 Week 1
Monash’s
The Ferranti Sirius, 1962
First Computer :
24
FIT9131 Week 1
A modern Supercomputer
25
Sunway TaihuLight
World’s Fastest SuperComputer (June 2016)
FIT9131 Week 1
What is a computer?
26
FIT9131 Week 1
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.
27
FIT9131 Week 1
INPUT ???
Hardware
OUTPUT ???
output device
central processing unit (cpu)
main memory
input device
STORAGE ???
secondary storage device
28
FIT9131 Week 1
OUTPUT
screen, printer, plotter, speech synthesizer, paper tape...
INPUT
keyboard, mouse, joystick, bar code reader, scanner, paper tape, cards...
Hardware
output device
central processing unit (cpu)
main memory
input device
STORAGE
magnetic disk, CD- ROM, USB flash disk, tape, ...
secondary storage device
29
FIT9131 Week 1
Hardware
output device
central processing unit (cpu)
1001011110101 0111010001110 1101001011001
input device
secondary storage device
Program(s), in binary code
30
FIT9131 Week 1
31
Software
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)
FIT9131 Week 1
Program Data
32
Computer
Output
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
FIT9131 Week 1
History of programming languages
artificial intelligence
ORACLE, SEQUEL, INGRES, ...
5GLs
4GLs
HIGH-LEVEL LANGUAGES
FORTRAN, COBOL, C,
LISP, Pascal, C++, C#, Java ...
ASSEMBLER LANGUAGES MACHINE CODE
33
FIT9131 Week 1
Language history
ALGOL 58 ALGOL 60
SIMULA I SIMULA 67
FORTRAN I FORTRAN II
FLOW-MATIC COBOL
COMTRAN 1950 LISP 1960
CPL
1965
PROLOG 1970 1975
FORTRAN IV
BASIC PL/1
BCPL
B C
ALGOL 68
PASCAL
MODULA 2
SMALLTALK 80
1980
1985 1990
1995
ADA EIFFEL
34
C++
OBERON
MODULA 3
BETA
C#
JAVA
BlueJ
(not a language!) 2000
FIT9131 Week 1
Different programming languages
Low-level
Machine code
• 000 100C • 006 300D • 007 200D • 100
• 110
COBOL FORTRAN LISP Pascal Java
Assembler
LDA VALUE ADA TOTAL STA TOTAL DW1 TOTAL DW1 VALUE
ADD VALUE TO TOTAL
TOTAL = TOTAL + VALUE
(set! total (+ total value)) total := total + value total += value;
High-level
35
FIT9131 Week 1
Program translation
36
• 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
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.
37
FIT9131 Week 1
Program translation
Source code written in high-level language (eg. Pascal, C++, Java)
Executable code in binary (10110.....)
Language translators (compilers, interpreters)
38
FIT9131 Week 1
Java program translation
39
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
Java program translation
“machine-neutral”
Source code written in Java
Java bytecode (21416....)
Executable code in binary (10110.....)
Java interpreter (Java Virtual Machine)
“machine-dependent”
40
Java compiler
FIT9131 Week 1
Java : write once, run anywhere!
41
• 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
Executing a Java program
Editor
Java source code
On remote computer?
(Maybe)
On local computer
Java compiler
bytecodes
Java interpreter
JVM
Bytecode
Verifier
42
bytecodes
copy of
bytecodes
FIT9131 Week 1
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; }
}
43
FIT9131 Week 1
Java and
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.
BlueJ
44
FIT9131 Week 1
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.
45
FIT9131 Week 1
Object
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
-
oriented programs
46
FIT9131 Week 1
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.
47
FIT9131 Week 1
Attributes and
Behaviour
Eg :
Attributes
Behaviour
Car
Registration number Manufacturer Model
Year
Colour
Start
Stop
Turn Accelerate
Cat
Name
Breed
Colour
Age
Weight
Registration number
Sleep Eat Purr Climb Scratch
48
FIT9131 Week 1
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?
49
FIT9131 Week 1
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
sleep eat purr climb scratch
Class Name
Attributes
A Class Diagram
Behaviour
50
FIT9131 Week 1
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.
51
FIT9131 Week 1
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.
52
FIT9131 Week 1
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).
53
FIT9131 Week 1
Making something happen
54
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.