0% found this document useful (0 votes)
36 views55 pages

CSIT111 Lecture 1

CSIT111 Programming Fundamentals is a 6 credit point subject that introduces students to fundamental computing concepts and the principles of Java programming through lectures, labs, assignments, and assessments; it covers topics like sequential designs, classes and objects, and arrays; students will complete 3 assignments, labs, quizzes, a mid-term test, and a final exam as part of the coursework.

Uploaded by

jeffreytoh1996
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views55 pages

CSIT111 Lecture 1

CSIT111 Programming Fundamentals is a 6 credit point subject that introduces students to fundamental computing concepts and the principles of Java programming through lectures, labs, assignments, and assessments; it covers topics like sequential designs, classes and objects, and arrays; students will complete 3 assignments, labs, quizzes, a mid-term test, and a final exam as part of the coursework.

Uploaded by

jeffreytoh1996
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

CSIT111 Programming Fundamentals

Dr Heng Aik Koan


[email protected]
Course account:
https://moodle.uowplatform.edu.au

1
Reference books
Recommended Textbook
Java how to Program (Early Objects), Eleventh Edition, Paul
Deitel and Harvey Deitel, Pearson, 2018

Important Reference Books


Introduction to Java Programming Comprehensive, Eleventh
Edition, Liang, Pearson 2018

Java programming, Eighth Edition, Joyce Farrell, Cengage


learning 2016

Java programming: From problem solving to design, Fifth


edition, D.S Malik, Cengage learning 2012

2
Lecture Plan

1. What you need to know about lectures,


labs, assignments and exams
2. What Programming Fundamentals is and
how it is related to your degree

3
Subject structure

• Assignments : 3 assignments
• Quizzes: at least 3
• Labs: at least 5

This is a 6 credit point subject. According to Course Rule


003 the amount of time spent on this subject should be at
least 12 hours per week including self-directed study

4
Assessment
Assessment Items % Remarks
Assignment 1 7% Sequential designs
Assignment 2 8% Classes and objects
Assignment 3 8% Arrays
Labs and Quizzes 12%
Closed book term test 15% Around 3rd last lessons
Closed book written exam 50%

Don’t wish to get a lot of marks in the final exam to


compensate what have been lost in labs and assignments
5
Lectures

• The lectures will introduce fundamental computing


concepts and the principles of Java programming
• The lectures will contain a sufficient number of examples
and slides with animation to facilitate explanation of
complex technical aspects
• It is highly recommended that you implement all
examples, compile and run the programs on your
computer
• You are encouraged to participate actively in the lecture
sessions answering questions and making your own notes
that will help you to understand material better
( see a list of scheduled lecture topics in the subject outline )

6
Labs
• All labs are take home lab. You should try your best to finish
your lab in one or two days.

•All labs and the assignments need to be demonstrated in


class.

7
Assignments
• There will be three programming assignments
• When an assignment is released, download the
assignment description from the subject web site. Read
carefully the specifications. Make sure you understand the
requirements.
• Take home assignments for programming parts
• Your solutions must be submitted electronically via the
Moodle system. No submission via email will be
accepted
• Late assignments will not be accepted without a
granted special consideration
• Exact time after which the submitted assignment will not
be accepted by the system will be indicated in every
assignment

8
Assignments
• When you submit an assignment, you need to follow the
submission instructions for this assignment and do not
make any assumptions
• In every submitted assignment file you submit must
include the following information header :
/*------------------------------------------------------
My name:
My student number:
Tutorial group:
Declaration: Make a declaration telling me if this is
your own work
-------------------------------------------------------*/
• No header, or an empty header is considered as an anonymous
submission. Such assignments are not marked (your mark will be 0)
• Make sure the submitted files are named as required. Files
submitted with incorrect names are not recognized by the assignment
9
test system and are not marked (your mark will be 0)
Assignments FAQ
1. How to submit my assignment electronically?
- Via Moodle system

2. What development environment and Java version can I use?


You can use any development environment to work on assignments at home.

10
Assignments
All assignments must be completed individually
When you submit an assessment task, you are declaring
the following:
1. It is your own work and you have not copied anything from others
and you have not discussed your work with others
2. You have not plagiarized from published work (including various
internet sources)
3. You have read your responsibilities under the UOW’s policy on
plagiarism and you understand possible consequences
4. You have not used storage devices which can be accessed by
others without passwords
Plagiarism = Big problems
You may be asked to have a formal meeting with the
lecturer to explain your assignment solution if there are
doubts that you worked on your assignment yourself
11
Subject web site
The subject web site is the subject’s “Notice Board”

All important notices related to CSIT111 will be posted


there. Check it frequently !

Note: Any information posted to the subject web site is


deemed to have been notified to all students

12
Self-directed Study
Listening passively is useless
• Download lecture notes from the subject web site and
look through the lecture notes prior to lectures
• Attend all lectures. Take your own notes and add your
own comments or questions during the lectures
• Read related chapters in the textbook together with
lecture notes and implement Java examples discussed at
lectures on your computer at home
• Should you have any questions, ask!!

But you will talk to a person


who has hearing problem …..

13
Subject Materials

Lecture notes:
The lecture notes are available on the subject web site
The lecture notes may not include some examples and
explanations given in lectures

14
Introduction
to
Programming Fundamentals

15
Digital World
In modern life, we are surrounded by digital electronic
devices

Microprocessors + Programs

16
Digital World

Automatic parking Self driving cars


Smart cruise control

Military robots

Home robots

Automated assembly lines


17
Computers are incredibly fast, accurate and stupid.
Human beings are incredibly slow, inaccurate and brilliant.
Together they are powerful beyond imagination.
Albert Einstein?… Leo Cherne?... Stuart Walesh?

How to let this stupid machine


do something for me?

Bundesarchiv, B 145 Bild-F077948-0006 / Engelbert Reineke / CC-BY-SA 3.0


18
Personal Computer
640K ought to be enough for anybody
Bill Gates, co-founder of Microsoft Corporation, 1981

1) Scanner
2) CPU (Microprocessor)
3) Memory (RAM)
4) Expansion cards
(graphics cards, etc.)
5) Power supply
6) Optical disc drive
7) Storage (Hard disk or SSD)
8) Motherboard
9) Speakers
10) Monitor
11) System software
12) Application software
13) Keyboard
14) Mouse
15) External hard disk
By User:HereToHelp, CC BY 2.5 16) Printer

One of the most


important components
is missing here
19
Let a computer do something!

Computers don't do anything without someone telling them what to do

–How to let a computer to do something?


• Instruct it
–How to instruct a computer to do something?
• Use a language to instruct it
–How to use a language to instruct a computer to do something?
• Write a sequence of instructions in a language – a program
–How to write a program?
• Learn programming – this subject !

20
How computers work

The focus of CSIT111

By Golftheman, CC BY-SA 3.0


System Software

By Kristoferb, CC BY-SA 3.0

/**
* The HelloWorldApp class implements an
* application that displays “Hello world!"
* to the standard output.
*/
class HelloWorldApp {
public static void main(String[] args){
// Display "Hello world!"
System.out.println("Hello world!");
}
21 }
How computer programs work
x86 instructions
-----------------------
ADD add
SUB substract
MUL multiply
Central CMP compare
INC increment
Processing MOV move data
Unit …
input output
(CPU)
program in memory

Program
Task:
Code
machine
instructions
z=x+y
00FF 01101001 read CPU instructions
01101010 read
00FF:F0F0
… add
main 00FF:F0F1 11100101 write Read location x
≈ Read location y
memory Program
Data
Add
10000100 x Write to location z
≈ 01001011 y
… z

The instruction binaries are not real and for illustration only
22
Evolution of Programming Languages
Machine Symbolic High-level

languages languages languages

1950 1950 1960

10001101 mov al,40 weight = mass * 9.8;

00111100 add al,dl if(weight > MAX_WEIGHT)

00101101 cmp cl,dl status = sendWarning();

11000101 call RESET

• 1989 – C was standardised by the ANSI/ISO


• 1998 – C++ was standardised by the ANSI/ISO
• 1995 – Java 1.0 was released by Sun Microsystems
Java has not been formally standardised by the ISO. It is a de facto
industrial standard controlled through the JCP since 1998
23
Task: “Hello, world!”
• How do people say hello to the world?
Hello
G’day
你好
Bonjour
‫مرحبا‬
こんにちは
여보세요

• How to instruct your computer to say hello to the


world ?

24
“Hello world” programs

Intel x86 instruction set for 32-bit Linux


Intel x86 instruction set for 16-bit DOS
.model small section .data
.stack 100h str: db 'Hello world!', 0Ah
str_len: equ $ - str 01011001
.data section .text 11100100

Assembly
msg db ‘Hello world!$' global _start …
_start: compiled 10100101
.code mov eax, 4
start: mov ebx, 1
11000100
mov ah, 09h mov ecx, str 01101011
lea dx, msg mov edx, str_len …
int 21h int 80h
mov ax, 4C00h mov eax, 1
int 21h mov ebx, 0 Machine code
end start int 80h
Low
Levels of programming languages

#include <stdio.h>
compiled
int main() {
C
printf("Hello World!");
VM VM
}

public class HelloWorldApp {


public static void main(String[] args){ compiled
System.out.println("Hello, World!"); Java
}
}
High

interpreted
print "Hello World!" Python
25
Programming languages
Anything that can be done using one
• Compiled languages language can be done using any language.
– Compiled to machine code Some language may be easier for certain things

• Architecture-dependant, high performance


• Assembly, C, C++
– Compiled to bytecode
• Architecture-neutral (running in a virtual machine)
• Java
• Interpreted (scripting) languages
– Programming languages without explicit compilation, interpreted at
run-time
• JavaScript, PHP, Perl, shell
• Python is used without compilation, but is compiled to bytecode on-the-fly and
running in a virtual machine
– Simple and less lines of code, less access to computer native
resources, slower execution
The differences are becoming fewer

26
Why Java?
• General-purpose language
– Suitable for a wide range of applications
• Supports the most advanced software development concepts
– class-based, object-oriented, concurrent
• Architecture-neutral, portable
– write once, run anywhere
• Most popular
– Java is everywhere
• 97% of enterprise desktops run Java
• 3 billion mobile phones run Java
• 100% of Blu-ray disc players ship with Java
• 5 billion smart cards run Java Card applets
• 125 million TVs run Java
• Java powers set-top boxes, printers, Web cams, games, car navigation systems, lottery
terminals, medical devices, parking payment stations, and more
– 9 million programmers/developers
– Books, tutorials, exercises, compilers, environments are just as numerous
as stars If one is a good master of one programming language,
one would have few difficulties to pick up another quickly
27
TIOBE Programming Community Index
Long term trends for top 10 programming languages

Popular search engines such as


Google, Yahoo!, Wikipedia,
Amazon, YouTube and Baidu
are used to calculate the ratings

28 Viewed in July 2016 at www.tiobe.com/tiobe_index


Programming Language Index

The PYPL PopularitY of


Programming Language Index
is created by analysing how
often language tutorials are
searched on Google

29 Viewed in July 2016 at http://pypl.github.io/PYPL.html


Trendy Skills

Trendy Skills are


skills which
employers seek in
the IT industry

30 Viewed in July 2016 at trendyskills.com


Australian IT job market

2013 2014 2015 2016


Keywords Job Title: Developer Category: IT Category: IT Category: IT

Java 80 47.6% 60 56.1% 355 66.6% 229 55.4%


C# 76 45.2% 34 31.8% 158 29.6% 173 41.8%
Objective C 12 7.1% 13 12.1% 20 3.8% 11 2.7%

Sorry, I don’t know


Singapore IT job market

31 Job search in July 2016 at www.careerone.com.au


Programming
• Programming is a problem-solving activity
– A program tells the computer how to solve a specific problem
– A problem can be broken down into a set of sub-problems
• There are many ways how a problem can be subdivided into sub-problems
• The subdivision affects the program implementation

• Programming is not very difficult, but time-consuming


– The most challenging part about programming is to match
subdivision of the problem with the program design methodology
– Computers cannot guess what problem you are solving. They
simply follow your program instructions even though they may be
wrong
– A lot of time will be spent to figure out why the computer does not
do what you expect it to do - debugging
Remember? Brilliant Humans beings are incredibly slow and inaccurate

32
The subject
• Objective
– Learn the fundamental principles of programming
• Object-oriented view of problem analysis and solving
• Learning Outcomes
1. Create and manipulate data types and structures.
2. Design and implement solutions using classes; implement
the behaviour of objects in a structured way.
3. Understand and apply the syntactic and semantic rules of an
object-oriented programming language.
4. Illustrate an understanding of tools and techniques for
program testing.
5. Illustrate an understanding of the concepts involved in
compilation, linking and execution
This subject is not just about Java, but you will learn programming in Java
33
Topics covered by CSIT111

1. Object-oriented design methodology

2. Java language basics


– Data types and structures
– Classes and objects
– Object-oriented programming
• object integration, Java libraries and class design

3. Java development environment


– Concepts of compilation/linkage/execution
– Program testing, maintaining and debugging

34
Topics not covered by CSIT111

• Java Virtual Machine


- Java is more than just a programming language

• Java platform and technology


– Relationship between classes – inheritance and polymorphism
– Concurrency (multi-threads)
– GUI (Graphic User Interface) and graphics
– Networking
– Database connectivity
– Enterprise, Micro (Card and TV) and Embedded Java

35
Learning programming
• Learn by doing
• If you want to learn programming, you must “do” programming
• Spend sufficient time doing it

Learning stage Applying stage

Lectures Labs Assignments


Apply
Discuss Do it
what learnt
with examples like examples from examples

• You should listen to what • You must do exercises if you


the lecturer says about what want to learn programming. • When you are ready, you will
on the presentation slides; • If you do not spend sufficient find assignments not very
• Slides are not for you to time to actually write actual difficult to complete
read - books are code, you are not learning
programming.
36
Programming Process

Text Editor
Source
A text file
Code
File

Compiler
run
Executable
File

Debugger

37
Java Programming Process

• Implement a program
Java Program
– Use any text editor to write it
HelloWorldApp.java
– Save text into a file
HelloWorldApp.java
Compiler
HelloWorldApp.class
• Compile a program: compiler
– javac HelloWorldApp.java bytecode
Java bytecode is hardware platform independent

• Executing a program: interpreter JVM JVM


– java HelloWorldApp 11000110101 01001010101
00000110100 11010110100

JVM translates bytecode into hardware


platform dependent microprocessor instructions Windows Unix

38
Java Program Execution
• The basic structural unit of a Java program is a class
• Instances of classes placed in memory become objects
Java Class Library Verification checks if bytecode is safe
and cannot crash the computer

Class 1 ... Class N Java Virtual Machine

Bytecode Verifier

Virtual
Class A Class memory
main(..) Loader
Execution
Class B Engine

Class C 11000110101
JVM loads all application 00000110100
Java Application A components class-by-class
39
1. Write your program
/**
* The HelloWorldApp class implements an application
* that displays “Hello world!" to the standard
* output.
*/
class HelloWorldApp{
public static void main(String[] args){
// Display “Hello world!"
System.out.println(“Hello world!");
A predefined
object
}
}

Text editors for programmers: OS Editors


- Pure text based (no graphics, etc) Windows Notepad++
- Syntax highlighting Linux (desktop) gEdit, nEdit
- Note: word processors are not suitable Linux/Unix/Mac (CLI) pico/nano (no syntax highlighting)
source code editors vim/emacs (not for beginners)
• MS Word Mac TextMate
• FrameMaker
40
1. Write your program
- Source code must be properly formatted using whitespace
- Chaotic indentation makes a program code messy

class HelloWorldApp {public static void main(String[]


args){System.out.println("Hello world!");}}

class HelloWorldApp
{public static void main(String[]
args){System.out.println("Hello world!");}}

Such code can be compiled, but you will lose marks for
submitting such code of bad style resulting in poor
readability
41
2. Compile and run your program
• To compile your program you need
Java Development Kit (JDK) that includes
- javac Java compiler
- Java Virtual Machine
- Java APIs
- other components and tools

• To run your program you need


Java Runtime Environment (JRE) that is a subset of JDK
- java Java application loader
- Java Virtual Machine There is no need to install JRE
if you have installed JDK
- Java Class Library
- other components
42
Basic development environment
Notepad++ Command Prompt

Windows
Explorer

43
Integrated Development Environment
• Although JDK provides all tools needed for
compiling, debugging, running and
documenting your program, you may find it
more convenient to use an application that
integrates all tools and provides a
convenient graphical user interface

• Integrated Development Environments IDE Remarks


(IDE) BlueJ Beginners
– Text editor + Compiler + debugger + code manager NetBeans Full featured
– Graphic user interface (window-based) Eclipse Industrial strength
– All platforms (Windows/Linux/Mac)
IntelliJ IDEA Android based on

A complex IDE does not help beginners to learn programming as it


increases productivity only when you know what to write.
You should first focus on what to write
44
Java versions
• Java has undergone substantial changes since it was
introduced in 1995
- syntax
- class library
- performance

1995 1997 1998 2000 2002 2004 2006 2011 2014


1.0 1.1 1.2 1.3 1.4 5 6 7 8

The latest release is Version 8 Update 171

• java –version command checks what version is


installed on your computer

45
Java version used for CSIT111
• CSIT111 is based on Java Standard Edition 8 (Java SE8)
- This version supports all features needed to develop desktop and
server applications.
• Java SE8 adds support of a new programming concept -
functional programming (not covered by CSIT111)
• The Java Enterprise Edition (Java EE) is focused mostly on
developing large-scale, distributed networking applications
(not covered by CSIT111)

1. Download JDK SE from www.oracle.com and install on your


computer
2. Download and install Notepad++ source code editor

46
First Program
/**
* The HelloWorldApp class implements an application
* that displays “Hello world!" to the standard
* output. a bug
*/ ) is missing
class HelloWorldApp{
a bug
public static void main( String[] args {
// Display “Hello world!" n is missing
System.out.printl ("Hello world!"); Compilation errors
}
}

• Everything in a Java
program must be inside a
class
• Class – a container for the
program logic that defines
the behaviour of which all
Java applications are built
47
NetBeans IDE
• Once you get familiar with the basics of Java
programming, you can try using NetBeans IDE
• Although it is an advanced development tool, it is not hard to learn
how to use its basic features
- create a Java project
- edit source code files
- compile
- debug
- test run
• It supports many other things
which you don't need at this
stage
• NetBeans IDE does not have its own Java compiler. It uses JDK that
should be installed before you install NetBeans
48
NetBeans IDE
1. Create a new project or open an existing project Select Java Application

49
NetBeans IDE
2. Specify the project name, location of its folder and tick Create Main
Class. Then press Finish.

50
NetBeans IDE
3. A template source code will be generated that you can edit

51
NetBeans IDE
4. When you finish editing, you can compile you program by pressing
Build Project button

Code Analyser
may detect some
syntax errors even
before compilation

All compilation errors will be shown in this window


52
NetBeans IDE
5. When you fix reported bugs, you can re-compile you program by
pressing Build Project button again

Build Successful message


53
NetBeans IDE
5. After successful compilation you can run your application by pressing
Run Project button

Hello World message printed by the running application


54
Suggested reading

Java: How to Program (Early Objects), 11th Edition


• Preface
• Before you begin
• Chapter 1
1.2 Hardware and software
1.4 Machine languages
1.6 Operating systems
1.9 Java development environment

55

You might also like