ภาษาคอมพิวเตอร์และการพัฒนาโปรแกรม...

Post on 03-Jan-2016

20 views 4 download

description

ภาษาคอมพิวเตอร์และการพัฒนาโปรแกรม Programming Languages and Program Development. โปรแกรม ( Program). หมายถึงชุดคำสั่งที่เขียนด้วยภาษาโปรแกรมเพื่อบอกให้คอมพิวเตอร์ทำงานตามต้องการ. How People Make Programs. - PowerPoint PPT Presentation

Transcript of ภาษาคอมพิวเตอร์และการพัฒนาโปรแกรม...

ภาษาคอมพิ�วเตอร์ และการ์พิ�ฒนาโปร์แกร์ม

Programming Languages and Program Development

โปร์แกร์ม (Program)

หมายถึ�งชุ�ดค าสั่�"งที่$"เขี$ยนด&วยภาษาโปร์แกร์มเพิ'"อบอกให&คอมพิ�วเตอร์ ที่ างาน

ตามต&องการ์

How People Make Programs

Programming กร์ะบวนการ์แก&ป*ญหาโดยการ์เขี$ยนชุ�ดค าสั่�"งเป,นขี�-นตอนบอกให&คอมพิ�วเตอร์ ที่ างานตามความต&องการ์ขีองผู้/&ใชุ&

Computer Programs and Programming Languages

p. 664 Fig. 13-1 Next

Programming language—used to write instructions

How People Make Programs

– การก�าหนดปัญหา– การออกแบบ ตรวจสอบ และทดสอบ algorithm

– เขี�ยนโปัรแกรม– ตรวจสอบและแก�ไขีโปัรแกรม

Programming ร์วมถึ�ง :

Interpreters and Compilers

Interpreter: แต0ละค าสั่�"งจะถึ/กแปลที่�นที่$

• Compiler: จะปั�อนโปัรแกรมเขี�าไปัท��งหมดแล�วจ!งแปัลเปั"นภาษาเคร&'อง

Programming Languages and Methodologies

Machine language ค'อ ภาษาที่$"ใชุ&แที่นด&วยเลขีฐาน สั่อง ที่ าให&ม$การ์เขี$ยน การ์อ0าน และการ์แก&ไขีย�0งยาก

Assembly language เป,นภาษาสั่�ญล�กษณ์ ที่$"ใชุ&แที่น ด&วยต�วอ�กษร์ และง0ายต0อการ์เขี&าใจต0อการ์อ0านและการ์

เขี$ยน

ระบบคอมพิ*วเตอร+ท,กเคร&'องจะต�องม�ภาษาธรรมชาต* ขีองต�วเองค&อ machine language

Levels of Languages

Lower-level languages – เปร์$ยบเสั่ม'อนก�บเลขี 0และเลขี 1 ที่$"คอมพิ�วเตอร์ เขี&าใจ

Higher-level languages – เปร์$ยบ0สั่ม'อนก�บภาษาที่$"มน�ษย ใชุ&

Divided into five generations

p. 664 Next

Low-levellanguage

Low-levellanguage

คอมพิ�วเตอร์ จะเขี&าใจภาษาเคร์'"องตามชุน�ดขีองคอมพิ�วเตอร์

คอมพิ�วเตอร์ จะเขี&าใจภาษาเคร์'"องตามชุน�ดขีองคอมพิ�วเตอร์

ภาษาเคร์'"องและภาษาแอสั่แซมบล$จ�ดเป,นภาษาร์ะด�บต "า

ภาษาเคร์'"องและภาษาแอสั่แซมบล$จ�ดเป,นภาษาร์ะด�บต "า

p. 664 Next

High-level language

High-level language

เป,นภาษาคอมพิ�วเตอร์ ที่$"สั่ามาร์ถึน าไปใชุ&ก�บคอมพิ�วเตอร์ ได&ที่�กเคร์'"อง

เป,นภาษาคอมพิ�วเตอร์ ที่$"สั่ามาร์ถึน าไปใชุ&ก�บคอมพิ�วเตอร์ ได&ที่�กเคร์'"อง

Five Generations of Languages

1. Machine language2. Assembly languages3. High-level languages4. Very high-level languages5. Natural languages

1. Low-Level LanguagesWhat is machine language?

p. 665 Fig. 13-2 Next

โปร์แกร์มและต าแหน0งขีองหน0วยความจ าจะเขี$ยนในร์/ปขีองค0า 0s และ 1s

ป*ญหาขีองภาษาเคร์'"อง โปร์แกร์มเขี$ยนยากและต&อง

แก&ไขี คอมพิ�วเตอร์ แต0ละเคร์'"องจะม$

ภาษาเป,นขีองต�วเอง CPU และ หน0วยความจ าหล�กจะ

เชุ'"อมต0อผู้0านบ�สั่

2. Low-Level Languages

What is assembly language?

p. 666 Fig. 13-3 Next

ค าสั่�"งจะถึ/กก าหนดเป,นร์ห�สั่ในร์/ปขีองสั่�ญล�กษณ์ โดยใชุ&ต�วย0อและร์ห�สั่

Source program เป,นร์ห�สั่ขี&อม/ลที่$"ถึ/กเปล$"ยนเป,นภาษาเคร์'"อง

2. Assembly Languages

ต�วอย0าง A ใชุ&แที่นค0าบวก add, C ใชุ&แที่นว0า compare, etc.

“Adding values (Price and ShippingCharge) stored in memory”156C LD R5, Price166D LD R6, ShippingCharge5056 ADDI R0, R5 ,R6306E ST R0, TotalCostC000 HLT

3. Procedural Languages

p. 666 Next

ภาษาที่$"ใชุ&กว&างขีวางค'อ BASIC, COBOL, and C

การ์เขี$ยนค าสั่�"งเหม'อนก�บการ์เขี$ยนภาษาอ�งกฤษ

บางคร์�-งจ�ดอย/0ในภาษาย�คที่$" 3 third-generation third-generation language (3GL)language (3GL)

โปร์แกร์มเมอร์ เขี$ยนชุ�ดค าสั่�"งบอกให&คอมพิ�วเตอร์ ที่ างานตาม

ต&องการ์จนสั่มบ/ร์ณ์

High-Level Languages

Well known high-level programming languages include:

– FORTRAN (Formula Translation): เปั"นภาษาระด�บส/งภาษาแรกท�'น�ามาใช�ในเช*งธ,รก*จ

– COBOL (Common Business Oriented Language): เปั"นภาษาท�'พิ�ฒนาเพิ&'อใช�ในการแก�ปัญหาทางธ,รก*จ

High Level Languages

LISP (List Processing): เป,นภาษาที่$"พิ�ฒนาในการ์ปร์ะมวลผู้ลขี&อม/ลที่$"ไม0ใชุ0ต�วเลขีเป,นต�วอ�กขีร์ะ ค า หร์'อสั่�ญล�กษณ์ อ'"นๆ

BASIC (Beginners All-purpose Symbolic Instruction Code): เป,นภาษาที่$"พิ�ฒนาขี�-นมาเพิ'"อให&ใชุ&ง0ายต0อการ์เร์$ยนร์/&สั่ าหร์�บผู้/&เร์�"มต&น

High-Level Languages

Pascal: เป,นภาษาที่$"ออกแบบเป,นภาษาโคร์งสั่ร์&าง

C: เป,นการ์พิ�ฒนาขี�-นมาเพิ'"อเป,นเคร์'"องม'อสั่ าหร์�บการ์โปร์แกร์มร์ะบบปฏิ�บ�ต�การ์เชุ0นUNIX

Object-Oriented Programming Languages

What is C++?

Next

เป,นภาษาที่$"พิ�ฒนาต0อจากภาษาซ$ โดยการ์เพิ�-มความสั่ะดวกขี�-นมาสั่ าหร์�บการ์ที่ างานแบบเชุ�งว�ตถึ� (object-oriented)

ใชุ&ในการ์พิ�ฒนาฐานขี&อม/ลและการ์เขี$ยนโปร์แกร์มเว9บ

Object-Oriented Programming Languages

What is Java?

Next

พิ�ฒนาขี�-นมาโดยบร์�ษ�ที่ Sun Microsystems

ม$ล�กษร์ะเหม'อนก�บภาษา C++ เป,นแบบ just-in-time (JIT) compiler โดยการ์เปล$"ยน source code ให&เป,น machine code

Object-Oriented Programming LanguagesWhat is a visual programming language?

p. 671 Next

Programmer writes and implements

program in segments

Visual programming environment (VPE) allows developers to

drag and drop objects to build programs

Often used in Often used in RAD RAD (rapid application (rapid application

development) development) environmentenvironment

Sometimes calledSometimes calledfifth-generation fifth-generation

languagelanguage

Provides visual or Provides visual or graphical interface for graphical interface for creating source codecreating source code

Object-Oriented Programming LanguagesWhat is Visual Studio .NET 2003?

Next

Suite of visual programming languages and RAD tools .NET is set of technologies that allows program to run on Internet Visual Basic .NET 2003 is used to build complex object-based programs

Step 1. The programmer designs the user interface.

Step 2. The programmer assigns properties to each object on the form.

Step 4. The programmer tests the application.

Step 3. The programmer writes code to define the action of each command button.

Object-Oriented Programming LanguagesWhat is Delphi?

p. 673 Fig. 13-12 Next

Powerful visual programming tool Ideal for large-scale enterprise and Web

applications

Object-Oriented Programming Languages

What is PowerBuilder?

p. 674 Fig. 13-13 Next

Another powerful visual programming tool Best suited for Web-based and large-scale

object-oriented applications

Nonprocedural Languages and Program Development Tools

What is a fourth-generation language (4GL)?

p. 675 Fig. 13-15 Next

Nonprocedural language that allows access to data in database

Popular 4GL is SQL, query language that allows users to manage data in relational DBMS

Nonprocedural Languages and Program Development Tools

What is Visual Basic for Applications (VBA)?

p. 676 Fig. 13-17 Next

Macro programming language Macro—series of statements used to automate

tasks

Web Page Development

What is HTML (Hypertext Markup Language)?

p. 678 Fig. 13-18 Next

Used to create Web pages

Web Page Development

What is a scripting language?

Next

Typically easy to learn and use JavaScript—adds dynamic content and interactive elements to Web page

VBScript (Visual Basic, Scripting Edition)—adds intelligence and interactivity to Web page

Perl (Practical Extraction and Report Language)—has powerful text processing capabilities

Web Page Development

What is dynamic HTML (DHTML)?

p. 682 Fig. 13-21 Next

Allows developers to include more graphical interest and interactivity in Web page

Web Page Development

What are XHTML, XML, and WML?

p. 682 Next

Click to view Web Link,click Chapter 13, Click Web Link from left navigation, then click XML below Chapter 13

XHTML (Extensible HTML)

enables Web sites to be displayed more easily on microbrowsers

XML (Extensible Markup Language)

allows developers to create customized tags

WML (Wireless Markup Language)

allows developers to design pages specifically for microbrowsers

Includes features of HTML and XML

Uses wireless application protocol (WAP),

standard that specifies how wireless devices

communicate with Web

Server sends entire record to client, enabling client to do much of processing without

going back to server

FrontP

ag

FrontP

ag

ee

20032003

FlashFlash

MXMX

Web Page Development

What is Web page authoring software?

p. 683 Next

Creates sophisticated Web pages without using HTML Generates HTML

Dreamweave

Dreamweave

rrMXMX

The Program Development Cycle

What is the program development cycle?

p. 686 Fig. 13-24 Next

Steps programmers use to build computer programs

Programming team—Group of programmers working on program

The Programming Process

Program – a set of detailed, step-by-step instructions that directs the computer to do what you want it to do

Programming language – a set of rules that provides a way of telling the computer what operations to perform

Five main steps

Defining the problemPlanning the solutionCoding the programTesting the programDocumenting the program

1. Defining the Problemการ์ก าหนดป*ญหา

การ์ก าหนดค�ณ์สั่มบ�ต�ตามที่$"ก าหนด: ขี&อม/ลเขี&า ผู้ลล�พิธ์ ที่$"ต&องการ์ การ์ปร์ะมวลผู้ลขี&อม/ลเขี&าให&เป,นผู้ลล�พิธ์

น�กเขี$ยนโปร์แกร์มจะร์�บขี&อก าหนดร์ายละเอ$ยดจากน�กว�เคร์าะห ร์ะบบ หร์'อน�กเขี$ยนโปร์แกร์มอาจพิบก�บล/กค&าโดยตร์ง

2. Planning & Design the Solution

Algorithm – เป,นการ์ก าหนดร์ายละเอ$ยดขี�-นตอนขีองการ์แก&ป*ญหา

เคร์'"องม'อที่$"ชุ0วยในการ์วางแผู้นอ�ลกอร์�ที่�มม$หลายชุน�ด Desk-check the solution

การ์ก าหนดขี�-นตอนจะก าหนดด&วยด�นสั่อยและกร์ะดาษPlanning Tool:

Flowchart – เป,นการ์ใชุ&ภาพิแที่นขี�-นตอนขีองการ์ที่ างาน

Pseudocode – ล�กษณ์ะเหม'อนภาษาอ�งกฤษ Specifies algorithm with more

precision than you can in English, but less than a programming language

Programmer Programmer begins with general begins with general

design and moves toward design and moves toward detailed designdetailed design

Planning & Design Solution

What is involved in designing the solution?

p. 688 Next

Object-oriented Object-oriented designdesign

Structured Structured designdesign, sometimes , sometimes

called called top-down designtop-down design

Two Two approachesapproaches

Devise Devise solution solution algorithmalgorithm, , step-by-step step-by-step procedureprocedure to solve to solve problemproblem

Step 2 — Design Solution

What is a hierarchy chart?

p. 688 Fig. 13-26 Next

Shows program modules graphically Also called structure chart

Step 2 — Design Solution

โคร์งสั่ร์&างการ์ควบค�มแบบเร์$ยงล าด�บ ?

p. 690 Fig. 13-28 Next

เป,นการ์แสั่ดงการ์ที่ างานตามล าด�บขีองก�จกร์ร์ม Control structure depicts logical order of program

instructions

Step 2 — Design Solution

โคร์งสั่ร์&างการ์ควบค�มแบบเล'อก ม$ 2 ชุน�ด ?

p. 690 Fig. 13-29 Next

Case control structure

If-then-else control structure—yields one of two possibilities: true or false

Step 2 — Design Solution

What is a case control structure?

p. 690 Fig. 13-30 Next

ม$การ์เล'อกที่างเป,นไปได&มากกว0า 3 ที่าง

Step 2 — Design Solution

What is a repetition control structure?

p. 691 Figs. 13-31–13-32 Next

Do-while control structure—ตรวจสอบเง&'อนไขีจนกระท�'งเปั"นจร*งแล�วจ!งออกจากการวนรอบ

Do-While Control Structure

Do-Until Control Structure

Do-until control structure—ท�างานจนกระท�'งเง&'อนไขีเปั"นจร*งจ!งออกจากการวนรอบ

Step 2 — Design Solution

What is a program flowchart?

p. 692 Fig. 13-33 Next

เป,นภาพิสั่�ญ�กษณ์ แสั่ดงขี�-นตอนในการ์แก&ป*ญหา

Step 2 — Design Solution

What is an example of a flowchart?

p. 692 Fig. 13-34 Next

Step 2 — Design Solution

What is pseudocode?

p. 694 Fig. 13-36 Next

เป,นค าสั่�"งเที่$ยมที่$"ม$การ์เขี$ยนขี�-นตอนเหม'อนก�บภาษาอ�งกฤษ

3. Coding the Programเป,นการ์เปล$"ยนอ�ลกอร์�ที่�มที่$"ได&จากการ์วางแผู้นให&อย/0ในร์/ป

ขีองภาษาคอมพิ�วเตอร์ ภาษาคอมพิ�วเตอร์ ที่�-งหมดจะม$ syntax rules

เหม'อนก�บ grammatical rules คอมพิ�วเตอร์ จะไม0ร์�บโปร์แกร์มที่$"เขี$ยนผู้�ดพิลาด

Programs can be keyed into the computer by using a text editor

4. Testing the Program

Two phases of testing the program Translation

Converting the program you wrote into the binary instructions the CPU understands (object codes)

Debugging Identifying and correcting logic errors

in the program

5.Documenting the Program

Materials are generated at each part of the process

Common examples of documentation Flowchart and/or pseudocode Comments within the source code Testing procedures Layouts of input and output records A narrative description of the

program