Overview of Computers Computer Hardware Computer Software Programming Languages Processing A Program Software Development Method
Overview of Computers Computer Hardware Computer Software Programming Languages Processing A Program Software Development Method
O
O Programming Methodology I
P
Professor: Aishy Amer
COEN243 Topic 01
Introduction
Overview of Computers
Computer Hardware
Computer Software
Programming Languages
Processing a Program
C++:
4
O Introduction
O
P
5
O 1.1 Overview of Computers
O
P
Computers / Programs:
– tools to solve real-world problems
Programs are used to simulate the behavior of
real-world systems
Simulation:
6
O Overview of Computers
O
P
Very Large Scale Integration (VLSI)
technology made computers affordable, small
and available to the public
Programming facilitates the use of computers
Programming has changed over time:
– Every few years a new programming language
Computer:
– “A device for counting or computing”
– Two components: Hardware & Software
7
O 1.2 Computer Hardware
O
P
Every computer is organized roughly into six
parts
– CPU - central processing unit
• decisions are made
• computations are performed
• input/output requests are delegated
– Main Memory
• Stores information being processed by the CPU
8
O Computer Hardware
O
P
– Secondary Memory
• Stores data and programs
– Input devices
• Allows people to supply information to computers
– Output devices
• Allows people to receive information from computers
– Network connection
• Modems / Ethernet interface
9
O Computer Components
O
P
10
O Main Memory
O
P
It stores
– programs
– data
– results
Types of memory
– RAM
– ROM
11
O Main Memory (2)
O
P Address Content
0 -27.2
Memory:
1 354
an ordered sequence
of storage locations 107 RTV0001
called memory cells 108
ADD1024
109
STR0005
Every cell has a content
1023 0.005
1024 75.62
12
O Main Memory (3)
O
P
To access cell info:
– each cell has a unique address
Content may or may not be meaningful to our
program
A cell =
01234567 a bit
byte
Binary:
– a numbering system of two numbers 0 & 1
Bit = Binary digit:
– Smallest element a computer can deal with
14
O Main Memory (5)
O
P
Assume a byte is composed of 1, 2,3, or 8 bits
If 1 bit: it can take 2 combinations
– 0 or 1
If 2 bits: it can take 4 combinations
– 00 01 10 11
If 3 bits: 8 combinations
– 000 001 010 … 111
Often a byte = 8 bits
– 2^8=256 combinations or values
15
O Secondary Memory & Storage
O
P
16
O CPU
O
P
17
O CPU (2)
O
P
Fundamental building block is a switch
– Switches are made from ultra-small transistors
Examples
18
O Input / Output Devices
O
P
Accessories that allow computer to perform
specific tasks
– Receiving information for processing
– Return the results of processing
– Store information
Common input and output devices
– Printer Joystick CD-ROM
– Keyboard Monitor
19
O Computer Networks
O
P
20
O 1.3 Computer Software
O
P
Application software
– Programs designed to perform specific tasks that
are transparent to the user
System software
– Programs that support the execution and
development of other programs
– Two major types
• Operating systems
• Translation systems
21
O Application Software
O
P
Application software has made using
computers indispensable and popular
Common application software
– Word processors
– Desktop publishing programs
– Spreadsheets
– Presentation managers
– Drawing programs
22
O Operating System (OS)
O
P
Controls and manages the computing resources
Important services of an OS
– File system
– Commands for manipulation of the file system
– Perform input and output on a variety of devices
– Management of the running systems
Examples
– Unix ®, Linux ®
– MSDOS ®, Windows ®
23
O 1.4 Programming Languages
O
P
Every few years:
– a new programming language
Programming language:
– evolved to help programmer
– To ease the transition from the design to
implementation
First language:
– Very dependent on the machine architecture
24
O Programming Languages (2)
O
P
Machine Language
– “Native tongue” of the computer
– Binary 0s and 1s that specify what to do
• 0010 0000 0000 0100
• 1000 0000 0000 0101
• 0011 0000 0000 0110
High - Level Languages
– Resemble human language (C++, C, Pascal)
• cost = price + tax;
25
O Programming Languages (3)
O
P
Language Standard
– Syntax (grammatical form) (rules)
– Portable
• programs used without modification
Example:
if(tax >10)
price= price * 3;
else if(tax>5)
price=price*2;
26
O Programming Languages (4)
O
P
Source Program: tax.cc
– Program you write
Object Program: tax.o
– Program translated from your program
Executable Program: tax
– Program translated from the object program
27
O Programming Languages (5)
O
P
Programming paradigm:
– design philosophy that helps to
• think about problems &
• formulate solutions
Examples:
– imperative languages
– structured languages
– object-oriented languages
28
O Imperative Programming
O
P
A computer:
– a large memory store
A program:
– a sequence of commands stored in the store
Emphasis on stored data
Examples: Assembly, Basic
29
O Structured Programming
O
P
A program:
– a set of procedures (or functions) on
a set of data values stored in the memory
Emphasis on functions
Function:
30
O Structured Programming (2)
O
P
Algorithms are the basis for the functions
– Highly structured
– Top-down design
– Step-wise refinement
Abstraction:
31
O Object Oriented Programming
O (OOP)
P
Real-world problems have objects
– Objects define the problem
OOP promotes thinking about software in a
way that models the real world
OOP supports good software engineering
32
O OOP (2)
O
P
Emphasis is on
– the objects (data) and
– how to manipulate them
A program:
– A network of objects with their attributes
– Attributes = data and operations
34
O OOP - Classes
O
P
A class:
– A definition of something
A class is an entity that defines the attributes
of an object
Attributes include data and operations
(methods)
35
O OOP – Classes (2)
O
P
Class:
– An instance of a class
A bank Account is a class
A particular bank account (yours) is an object
36
O Classes Hierarchy
O
P
Assume you want to define a new class
similar to a predefined class
Example:
– Bank-Account
• Saving Account
International Account
37
O Classes Hierarchy (2)
O
P
The new class (sub class):
– similar to the original class (super class)
– but with additional attributes
Subclass inherits all attributes of a super class
Classes are organized in a hierarchy
– Super Classes
– Sub Classes
38
O Classes Hierarchy Example
O
P
All kinds of accounts – Super Class
– float balance;
Savings account only – Sub Class
– float rate;
Checking accounts only – Another Sub Class
– float fee;
39
O OOP – Class examples
O
P
class time
{
private: hour, minute, second
public: setHour, setMinute, …
}
class student
{
private: name, address, ID, …
public: setName, setID, …
}
40
O 1.5 Object Oriented Design
O
P
Abstraction
41
O Object Oriented Design (2)
O
P
Modularity
42
O Abstraction
O
P
object
43
O Abstraction (2)
O
P
44
O Encapsulation
O
P
Breaking down an object into parts,
– hiding and protecting its essential information and
– supplying an interface to modify the information
in a controlled and useful manner
By hiding the information its representation
and content can be changed without affecting
other parts of the system
45
O Encapsulation (2)
O
P
46
O Modularity
O
P
Dividing an object so that the object holds
useful information and it is easier to
understand
Most complex systems are modular
– Cooling System
– Ignition System
– Fuel System
47
O Modularity (2)
O
P
Example - Automobile can be decomposed
into subsystems
– Cooling system
• Radiator
• Thermostat
• Water pump
– Ignition system
• Battery
• Starter
• Spark plugs
48
O Hierarchy
O
P
49
O 1.6 Processing a High-Level
O Language Program
P
Processing is a set of programs used to
develop software
A key component is a translator
Types of translators
– Compiler
– Linker
Examples
50
O Processing a Program (2)
O
P
Editor used to enter the program
– Source program (file.cpp)
– UNIX nedit text editor
Compiler translates the source program
– Displays syntax errors (not descriptive)
Linker/Loader to combine object file with
other object files
– Executable program
51
O Processing a Program (3)
O
P
Major activities
– Editing
– Compiling
– Linking with pre-compiled files
• Object files
• Library modules
– Loading and executing
– Viewing the behavior of the program
52
O
O
P
Process
Cycle
53
O 1.7 Software Development Method
O
P
Problem Analysis - (Correct Problem)
– Identify data objects
– Goal to model properties
– Determine Input / Output data
– Constraints on the problem
Design
55
O Software Development Method (3)
O
P
Software engineering
– Area of computer science concerned with building
large software systems
Challenge
56
O Software Engineering Goals
O
P
Reliability
57
O Software Engineering Goals (2)
O
P
Adaptability
58
O 1.8 Applying the Software
O Development Method
P
59
O Applying the Software
O
P Development Method
– Analysis
• The first step in solving this problem is to determine
what you are asked to do
• You must convert from one system of measurement to
another, but are you supposed to convert from
kilometers to miles, or vice versa?
• The problem states that you prefer to deal in metric
measurements, so you must convert distance
measurements in miles to kilometers
60
O Applying the Software
O
P Development Method
– Design
• The next step is to formulate the algorithm that solves
the problem
• Begin by listing the three major steps, or sub problems,
of the algorithm
– Implementation
• To implement the solution, you must write the
algorithm as a C++ program
– Testing
• How do you know the sample run is correct?
61
O 1.9 Professional Ethics
O for Programmers
P
62
O Ethics and Professionalism
O
P
Ethics:
– Disciplined dealing with moral duty
– Moral Principles or Practice
– System of right behavior
Professionalism:
63