0% found this document useful (0 votes)
20 views27 pages

LECTURE 04: Week 04: Introduction To Programming

The document discusses different programming languages and paradigms. It begins by describing early machine languages and assembly languages, and progresses to modern high-level languages like C++ and Java. It then covers structured programming, which divides programs into separate and reusable functions, and object-oriented programming, which packages data and behaviors into objects. The document provides examples of different programming paradigms and their basic terminology.

Uploaded by

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

LECTURE 04: Week 04: Introduction To Programming

The document discusses different programming languages and paradigms. It begins by describing early machine languages and assembly languages, and progresses to modern high-level languages like C++ and Java. It then covers structured programming, which divides programs into separate and reusable functions, and object-oriented programming, which packages data and behaviors into objects. The document provides examples of different programming paradigms and their basic terminology.

Uploaded by

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

LECTURE 04 : Week 04

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

 Assembler – program that translates an assembly


language program into machine language
Programming Languages
 Procedural Languages (High Level Languages)
(third generation languages)
 One instruction translates into many machine language
instructions
 Programs describe the computer’s processing step-by-
step
 Closer to natural language; uses common words rather
than abbreviated mnemonics
3
 Examples: C, Fortran, QuickBasic
 Programmer tells computer WHAT to do and HOW to
do
Intro. To Infor. & Comm . Tech
CSC-111
Programming Languages
 Nonprocedural Language
(fourth generation languages)
 Allows the user to specify the desired result without
having to specify the detailed procedures needed for
achieving the result
 Example: data base query language - SQL
 Can be used by non technical users
 Focus on WHAT to do, NOT HOW to do
4
 Natural Language Programming Languages
(fifth generation (intelligent) languages)
Intro. To Infor. & Comm . Tech

 Translates natural languages into a structured,


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

 Hypertext Markup Language (HTML)


 standard language used in World Wide Web
 contains text, images, and other types of information such
5
as data files, audio, video, and executable computer
programs
Intro. To Infor. & Comm . Tech
CSC-111

 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

 Common paradigms are,


7  Unstructured Programming
 Structured Programming
Intro. To Infor. & Comm . Tech

 Object Oriented Programming


CSC-111
Unstructured Programming
 In this approach programmer put all their
code in one place or say in one program.
when line of code increases, A programmer
can face so many problems like:

 Duplicity and redundancy of code


8  Code maintenance problem
 Readability and many more
Intro. To Infor. & Comm . Tech


CSC-111

This approach is totally useless if working on


a large project.
Structured Programming
 Program is divided into
separate functions
which was easier to
manage and re-use as
compared to
unstructured approach.
9

 This was very helpful


from reusability point of
Intro. To Infor. & Comm . Tech
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

 Complex problems can be solved using top-down design,


also known as stepwise refinement, where
10
 We break the problem into parts
 Then break the parts into smaller parts
 Soon, each of the parts will be easy to solve
Intro. To Infor. & Comm . Tech
CSC-111
CSC-110 Computing Fundamentals 11

STRUCTURED vs. OO PROGRAMMING


STRUCTURED PROGRAMMING:

MAIN PROGRAM GLOBAL DATA

FUNCTION FUNCTION 2 FUNCTION 3


1

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

OBJECT ORIENTED PROGRAMMING


CSC-110 Computing Fundamentals 16

OBJECT ORIENTED PROGRAMMING


Objects have both data and methods
Objects of the same class have the same data elements
and methods
Objects send and receive messages to invoke actions
 Key idea in object-oriented:

 The real world can be accurately described as a


collection of objects that interact.

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

We can think of an object


as a collection of properties
and the methods that are
used to manipulate those
properties.

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

Automobile Motorcycle Bus

Sedan Sports Car Luxury Bus School Bus

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

Any Questions !!!

You might also like