LECTURE 04: Week 04: Introduction To Programming
LECTURE 04: Week 04: Introduction To Programming
Introduction to Programming
Programming Languages
Machine Language
(first generation of programming languages)
The computer’s ‘native language’
Composed of binary digits (0s, 1s)
The only language that computers understand
Assembly Language
(second generation of programming languages)
2
One-to-one correspondence to machine language
Somewhat more user-friendly than machine language
(mnemonic rather than binary digits)
Intro. To Infor. & Comm . Tech
CSC-111
machine-readable form
Are extremely complex and experimental
Current Programming Languages
Visual Programming Languages
Used within a graphical environment
Example: Visual Basic and Visual C++
Popular to non technical users
Componentware
Software components that may be assembled by developer
as needed
Current Programming Languages
Object-Oriented Programming Languages (OOP)
based on objects – packaging data and the
instructions about what to do with that data
together
Examples: Java, C++
6
Intro. To Infor. & Comm . Tech
CSC-111
Programming Paradigm
A programming paradigm is a style or “way”
of programming.
A paradigm is a way of doing something (like
programming
CSC-111
view
Top-Down Development
If we look at a problem as a whole, it may seem
impossible to solve because it is so complex.
Examples:
Writing a library system
Writing a Bank System
FUNCTION 4 FUNCTION 5
11
Structured Programming
Using function
Function & program is divided into modules
Every module has its own data and function
which can be called by other modules.
12
Intro. To Infor. & Comm . Tech
CSC-111
OBJECT ORIENTED PROGRAMMING
Object 2
Object 1
Data Data
Function Function
Object 3
13
Data
Intro. To Infor. & Comm . Tech
CSC-111
Function
13
Basic terminology CSC-110 Computing Fundamentals 14
OBJECT
- usually a person, place or thing (a noun)
METHOD
- an action performed by an object (a verb)
ATTRIBUTE
- description of objects in a class
CLASS
- a category of similar objects (such as
automobiles)
- does not hold any values of the object’s attributes
14
CSC-111
15
Intro. To Infor. & Comm . Tech
16
Example for attributes and methods
Attributes: Methods:
manufacturer’s Define data items
name (specify
model name manufacturer’s
name, model, year,
year made
etc.)
color Change a data
17
number of doors item (color, engine,
size of engine etc.)
etc. Display data items
Intro. To Infor. & Comm . Tech
CSC-111
Calculate cost
etc.
CSC-110 Computing Fundamentals 18
Object-Oriented Programming
Properties
Methods
Why OOP?
Save development time (and cost) by
reusing code
once an object class is created it can be used
in other applications
Easier debugging
19 classes can be tested independently
reused objects have already been tested
Intro. To Infor. & Comm . Tech
CSC-111
19
Design Principles of OOP
Four main design principles of Object-
Oriented Programming(OOP):
Encapsulation
Abstraction
Polymorphism
20
Inheritance
Intro. To Infor. & Comm . Tech
CSC-111
20
Encapsulation
Also known as data hiding
Only object’s methods can modify information
in the object.
Analogy:
ATM machine can only update accounts of
21
one SPECIFIC person or object only.
Intro. To Infor. & Comm . Tech
CSC-111
21
CSC-110 Computing Fundamentals 22
Abstraction
Focus only on the important facts about the
problem at hand to design, produce, and describe
so that it can be easily used without knowing the
details of how it works.
Analogy:
When you drive a car, you don’t have to know how
the gasoline and air are mixed and ignited.
Instead you only have to know how to use the
controls.
Polymorphism
the same word or phrase can mean different
things in different contexts
Analogy:
In English, bank can mean side of a river or a
place to put money
23
move -
Intro. To Infor. & Comm . Tech
CSC-111
23
CSC-110 Computing Fundamentals 24
Inheritance
Inheritance—a way of organizing classes
Term comes from inheritance of traits like eye
color, hair color, and so on.
Classes with properties in common can be
grouped so that their common properties are only
defined once.
Superclass – inherit its attributes & methods to the
subclass(es).
Subclass – can inherit all its superclass attributes
& methods besides having its own unique attributes
& methods.
24
CSC-110 Computing Fundamentals 25
An Inheritance Hierarchy
Superclass
Vehicle
Subclasses
What properties does each vehicle inherit from the types of vehicles above it
in the diagram?
25
Object-Oriented Programming Languages
Pure OO Languages
Smalltalk, Eiffel, Actor, Java
26
Intro. To Infor. & Comm . Tech
CSC-111
26
27
CSC-111
27
Intro. To Infor. & Comm . Tech
END OF LECTURE