CSIT121 Lecture1
CSIT121 Lecture1
• Computer programs
• Programming languages
• What object-oriented means
• Object-oriented analysis (OOA)
• Object-oriented design (OOD)
• Object-oriented programming (OOP)
• Python IDLE
• Your first object-oriented program in Python
2
Digital World
In modern life, we are surrounded by digital electronic
devices
Microprocessors + Programs
Digital World
Military robots
Home robots
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
System Software
/**
* The HelloWorldApp class implements an
* application that displays “Hello object world!"
* to the standard output.
*/
class HelloWorldApp:
def greet(self):
// Display "Hello world!"
print("Hello object world!")
greeter = HellowWorldAPP()
greeter.greet()
How computers work
System Software
/**
* The HelloWorldApp class implements an
* application that displays “Hello object world!"
* to the standard output.
*/
class HelloWorldApp:
def greet(self):
// Display "Hello world!"
print("Hello object world!")
greeter = HellowWorldAPP()
greeter.greet()
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 11100101 write Read location x
≈ 00FF:F0F1
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
Evolution of Programming Languages
Machine Symbolic High-level
languages languages languages
• 1989 – C
• 1991 – Python
• 1995 – Java
• 1998 – C++
Task: “Hello, World!”
Assembly
msg db ‘Hello world!$'
_start: compiled 10100101
.code mov eax, 4
mov ebx, 1
11000100
start:
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
#include <stdio.h>
Levels of programming languages
interpreted
print "Hello World!" Python
Programming languages
• Objective
• Learn the Object-oriented view of problem analysis and solving
• Learning Outcomes
1. Effectively design and implement object-oriented programs in an
integrated development environment;
2. Demonstrate an understanding and appreciation of the concepts
of a well-structured solution and good coding style within an
object-oriented programming environment;
3. Create correct and maintainable object-oriented programs using
an object-oriented programming language;
4. Apply the principles of reuse in software design and
implementation
This subject is not just about Python, but you will learn programming in Python
Learning programming
• Learn by doing
• If you want to learn programming, you must “do” programming
• Spend sufficient time doing it
Discuss Do it Apply
what learnt
with examples like examples from examples
17
Object-oriented analysis, design
& programming
• Object-oriented means functionally directed toward modeling
objects.
• Terms:
• object-oriented analysis (OOA)
• object-oriented design (OOD)
• object-oriented programming (OOP)
18
Object-oriented analysis, design & programming
19
Object-oriented analysis
22
Object-oriented design
23
Object-oriented design
24
Object-oriented programing
25
Python
• interpreted
• targeted towards short to medium
sized projects
• useful as a scripting language
Runtime
Code Compiler Computer
Env
27
Python
Hello.java
1 public class Hello {
2 public static void main(String[] args){
3 System.out.println();
4 }
5 }
hello.py
1 def hello():
2 print "Hello \"world\"!"
3
4 def does_nothing():
5 pass
6
7 hello()
Python
comments.py
1 # This is a file full of comments and code.
Python can read the 2
function comments and 3 def hello():
make them available 4 """prints 'Hello world'
when you need them. 5 this comment can be multi-line"""
To access these 6 print "Hello world" # this is in-line
comments call 7 hello()
help(<function>).
>>> hello()
Hello world
>>> help(hello)
Help on function hello in module main :
hello()
prints 'Hello world'
this comment can be multi-line
Python – IDLE
32
Python IDE – IDLE
• https://www.python.org
33
Suggested reading
Python
• https://www.python.org/