Title: ENG236: Introduction (1)
1ENG236 Introduction (1)
THE HONG KONG POLYTECHNIC UNIVERSITY
Rocky K. C. Chang
2Computer Programming and Basic Software
Engineering
References
- J. Liberty, Teach Yourself C in 24 hours. SAMS,
2005/2009 (electronic book in the library). - H. M. Deitel and P. J. Deitel, C How To
Program, 6th Ed. Prentice Hall, 2008. - S. Prata, C Primer Plus. Fifth Edition, SAMS,
2005.
3Computer Programming and Basic Software
Engineering
Contents
- Introduction (week 1)
- A Taste of C (week 1)
- The Nuts and Bolts (weeks 2-5)
- Basic Software Engineering (weeks 6-7)
- Objects and Classes in C (weeks 8-9)
- Pointers and Arrays (weeks 10-13)
- Stream I/O
- Elementary Data Structure
- Building Graphical User Interface.
First semester
Second semester
4Getting Started 1. What is Computer Programming?
5Computer Programming
Computer Programming and Basic Software
Engineering
1. What is Computer Programming?
A systematic approach to instruct a computer
doing something for us.
Hardware
I/O devices
CPU
Memory
6Computer Programming and Basic Software
Engineering
1. What is Computer Programming?
Process of Computer Programming
Way of thinking
Computer
Computing Problems
Operating System
Hardware
Algorithms and Data Structures
Mapping
Coding
Application Software
High-level Language
Binding (Compile, link and load)
Details in the following slides
7Computing Problems
Operating System
Hardware
Algorithms and Data Structures
Mapping
Coding
Application Software
High-level Language
Binding (Compile, link and load)
8Computer Programming and Basic Software
Engineering
1. What is Computer Programming?
Identify the Problem
- Before writing a program, ask yourselves two
questions - What is the problem I want to solve?
- Do I really need to write a program to solve it?
- A problem can often be so large that requires the
co-operation of a few programs to solve it. - E.g. To design a computer game
- - Design the story
- - Design the graphics
- - Design the motion
-
9Computer Programming and Basic Software
Engineering
1. What is Computer Programming?
- Do we need to write a program for the following
problems? - Calculate the result of 1 1?
- Play a piece of MP3 music using the computer?
- Develop a Web page?
No. Just use your fingers!
No. Use application software such as Media Player.
Yes or no, depending on how complicated your Web
page is.
- Usually we need to write a program if the problem
is too complicated and specific to our needs.
10Computing Problems
Operating System
Hardware
Algorithms and Data Structures
Mapping
Coding
Application Software
High-level Language
Binding (Compile, link and load)
11Computer Programming and Basic Software
Engineering
1. What is Computer Programming?
Find the Best Algorithm
- A problem can be solved by different approaches
- Using a clever approach can save you a lot of
time in getting the result - E.g.
- Calculate 1 2 3 4 5 6 7 8 9
10 11 12 - Solution?
11 additions
Use algorithm 12 x (1 12) / 2 78 1 addition,
1 multiplication, 1 division
Seems better, BUT ...
12Computer Programming and Basic Software
Engineering
1. What is Computer Programming?
- Consider the following situation
- For a particular computer, it may take 10 ?s to
compute an addition but uses 100 ?s to do a
multiplication or division. - Calculate 1 2 3 4 5 6 7 8 9
10 11 12 - Do you still want to use algorithm?
? Algorithm needs to match with the hardware
architecture
13Computing Problems
Operating System
Hardware
Algorithms and Data Structures
Mapping
Coding
Application Software
High-level Language
Binding (Compile, link and load)
14Computer Programming and Basic Software
Engineering
1. What is Computer Programming?
Coding
- Computer can only understand 0 and 1.
- The most direct way to communicate with the
computer is to use 0 and 1. - ? Machine Language Programming
- 0110001111000010
- 0001000111100011
-
-
- 0011000100001000
- 1000001001010101
Machine Language Program
Very tedious and can make error easily
15Computer Programming and Basic Software
Engineering
1. What is Computer Programming?
Coding - Assembly Language
- Assembly Language is created to help human
instruct CPU to work. - By using a software tool called Assembler,
assembly language programs can be converted into
machine language programs.
Assembly Language
Machine Language
0110001111000010 0001000111100011 001100010000
1000 1000001001010101
LD R0, 05 ADD R0, 1234 SUB R0, 22 LD
2345, R0
Assembler
16Computer Programming and Basic Software
Engineering
1. What is Computer Programming?
Coding - High Level Language
- Assembly language programming is still too
complicated for general users. - They are very different from human languages.
- e.g. Set W equal to W plus X minus Y divided by
Z. - Repeat the next sequence of instructions until
X is less than 0 or Y equals Z. - A high level language is needed to reduce the gap
between human and computers.
17Computer Programming and Basic Software
Engineering
1. What is Computer Programming?
Details in the following slides
Executable Machine Language Program
Linker
1011010101 0101010101
.exe
Library
Object code
Give me the result of adding 1 to 10
Compiler
.cpp
High Level Program
18Computer Programming and Basic Software
Engineering
1. What is Computer Programming?
- Compiler Generate the object code.
- Object code ? Similar to the machine language
code but cannot be executed because of the
missing of some information. - Linker Resolve the missing information from the
library or other programs.
For a program, it is very common that some of the
information in the program needs to be obtained
from the Library provided by the programming
tool. It is the job of linker to obtain these
missing information.
19Computer Programming and Basic Software
Engineering
1. What is Computer Programming?
Coding - High Level Languages
- From time to time, high level languages (HLL) are
designed for different purposes. - Earlier examples
- BASIC for simple and general computing
(obsolete for long) - COBOL for data processing (is still using
in local banks) - FORTRAN for scientific computation (has
been replaced by C or C) - Recent examples
- Pascal a sophisticated but complicated
HLL (replaced by C or C) - C a simple structural HLL for general
computing (still in use) - Current examples
- C the most well-known object-oriented (OO)
language - Java an OO language designed with the
concept of networking.
20Computer Programming and Basic Software
Engineering
1. What is a Computer?
Programming - C
- Object-Oriented programming concept is
overwhelming. - OO Programming has the advantage of achieving
reuse of software components. - The C programming language is created to
implement the concept of OO programming. - C is an extension of the C language.
- C has become the predominant language for the
commercial software development. - Standardized by the American National Standards
Institute (ANSI), C program is portable to
different machines.
21Homework
- Install Visual Studio 2008 in your PC/notebook.
- Locate the electronic book Teach Yourself C in
24 hours.
22Acknowledgments
- The slides are based on the set developed by Dr.
Frank Leung (EIE).