Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 ENG236: Introduction (1) Rocky K. C. Chang THE HONG KONG POLYTECHNIC UNIVERSITY.

Similar presentations


Presentation on theme: "1 ENG236: Introduction (1) Rocky K. C. Chang THE HONG KONG POLYTECHNIC UNIVERSITY."— Presentation transcript:

1 1 ENG236: Introduction (1) Rocky K. C. Chang THE HONG KONG POLYTECHNIC UNIVERSITY

2 2 References: 1.J. Liberty, Teach Yourself C++ in 24 hours. SAMS, 2005/2009 (electronic book in the library). 2.H. M. Deitel and P. J. Deitel, C++ How To Program, 6th Ed. Prentice Hall, 2008. 3.S. Prata, C++ Primer Plus. Fifth Edition, SAMS, 2005. Computer Programming and Basic Software Engineering

3 3 Contents Computer Programming and Basic Software Engineering 1.Introduction (week 1) 2.A Taste of C++ (week 1) 3.The Nuts and Bolts (weeks 2-5) 4.Basic Software Engineering (weeks 6-7) 5.Objects and Classes in C++ (weeks 8-9) 6.Pointers and Arrays (weeks 10-13) 7.Stream I/O 8.Elementary Data Structure 9.Building Graphical User Interface. Second semester First semester

4 4 Getting Started 1. What is Computer Programming?

5 5 Computer Programming: A systematic approach to instruct a computer doing something for us. Computer Programming and Basic Software Engineering 1. What is Computer Programming? Hardware CPU Memory I/O devices

6 6 Process of Computer Programming Computing Problems Algorithms and Data Structures High-level Language Hardware Operating System Application Software Coding Binding (Compile, link and load) Mapping Computer Programming and Basic Software Engineering 1. What is Computer Programming? Details in the following slides Way of thinking Computer

7 7 Computing Problems Algorithms and Data Structures High-level Language Hardware Operating System Application Software Coding Binding (Compile, link and load) Mapping

8 8 Identify the Problem Before writing a program, ask yourselves two questions: 1.What is the problem I want to solve? 2.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 : Computer Programming and Basic Software Engineering 1. What is Computer Programming?

9 9 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. Computer Programming and Basic Software Engineering 1. What is Computer Programming?

10 10 Computing Problems Algorithms and Data Structures High-level Language Hardware Operating System Application Software Coding Binding (Compile, link and load) Mapping

11 11 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? Use algorithm:12 x (1 + 12) / 2 = 78 1 addition, 1 multiplication, 1 division Computer Programming and Basic Software Engineering 1. What is Computer Programming? 11 additions Seems better, BUT...

12 12 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? Direct addition: 110  sec Use algorithm: 210  sec  Algorithm needs to match with the hardware architecture Computer Programming and Basic Software Engineering 1. What is Computer Programming?

13 13 Computing Problems Algorithms and Data Structures High-level Language Hardware Operating System Application Software Coding Binding (Compile, link and load) Mapping

14 14 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 Computer Programming and Basic Software Engineering 1. What is Computer Programming?

15 15 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. Assembler 0110001111000010 0001000111100011 : 0011000100001000 1000001001010101 LD R0, #05 ADD R0, $1234 : SUB R0, #22 LD $2345, R0 Assembly LanguageMachine Language Computer Programming and Basic Software Engineering 1. What is Computer Programming?

16 16 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. Computer Programming and Basic Software Engineering 1. What is Computer Programming?

17 17 Give me the result of adding 1 to 10 Compiler Linker 1011010101 0101010101 : High Level Program Executable Machine Language Program Object code Library Computer Programming and Basic Software Engineering 1. What is Computer Programming?.exe.cpp Details in the following slides

18 18 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. Computer Programming and Basic Software Engineering 1. What is Computer Programming?

19 19 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. Computer Programming and Basic Software Engineering 1. What is Computer Programming?

20 20 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. Computer Programming and Basic Software Engineering 1. What is a Computer?

21 21 “Homework” Install Visual Studio 2008 in your PC/notebook. Locate the electronic book “Teach Yourself C++ in 24 hours.”

22 22 Acknowledgments The slides are based on the set developed by Dr. Frank Leung (EIE).


Download ppt "1 ENG236: Introduction (1) Rocky K. C. Chang THE HONG KONG POLYTECHNIC UNIVERSITY."

Similar presentations


Ads by Google