JSP คืออะไร

Download Report

Transcript JSP คืออะไร

หลักการภาษาชุดคาสัง่
Introduction
่ั
มหาวิทยาลัยเนชน
http://www.nation.ac.th
http://www.thaiall.com/programming
บุรน
ิ ทร ์ รุจจนพันธุ ์ .
ปร ับปรุง 18
Page: 1
กรกฎาคม 2556
คาอธิบายรายวิชา
ทฤษฎีของการออกแบบ และสร ้างภาษา
่
แนวคิดเกียวกั
บภาษาฟอร ์มัล รูปแบบ และ
้ ้น ชนิ ด และ
คุณลักษณะทางไวยากรณ์เบืองต
โครงสร ้างของข ้อมูล โครงสร ้างของการควบคุม
่
่
และการเคลือนที
ของข
้อมูล การพิจารณาเวลาใน
การประมวลผล อัลกอริทม
ึ แบบขนาน การออพติ
ไมซ ์ การออกแบบ และสร ้างลักษณะต่าง ๆ ของ
ภาษา ลักษณะเฉพาะของภาษาแบบโครงสร ้าง
บล๊อก แบบมอดูลาร ์ แบบเชิงวัตถุ ประเภทของ
ภาษาชุดคาสัง่ แบบกาหนดกระบวนการ และแบบ
http://www.thaiall.com/programming
Page: 2
วิวฒ
ั นาการ และประวัตข
ิ องแต่ละ
ภาษา
http://www.levenez.com/lang/
***
http://www.thaiall.com/programming/indexo.html
http://www.thaiall.com/article/teachpro.htm
http://www.thaiall.com/vb
http://www.thaiall.com/php
http://www.thaiall.com/assembly
http://www.thaiall.com/asp
http://www.thaiall.com/basic
http://www.thaiall.com/cobol
http://www.thaiall.com/pascal
http://www.thaiall.com/programming
Page: 3
กระบวนการแปลภาษา
กระบวนการแปลภาษา (Compilation
Process)
1. เลกซิคลั อนาไลเซอร ์ (Lexical
Analyzer)
2. ซินแทกซ ์ อนาไลเซอร ์ (Syntax
Analyzer)
3. ซีแมนติก อนาไลเซอร ์ (Semantic
ข ้อมูลจาก http://web.cecs.pdx.edu/~apt/cs321/ ***
Analyzer)
http://www.thaiall.com/programming
Page: 4
Compilation Process
Diagram
ข ้อมูลจาก http://web.cecs.pdx.edu/~apt/cs321/ ***
http://www.thaiall.com/programming
Page: 5
เลกซิคลั อนาไลเซอร ์ (Lexical
้
Analyzer)(1/5)
ขันตอนแรก
ทาหน้าที่ อ่าน
Source Code แล ้วแยกอักขระออกตาม
ลักษณะ และหน้าที่ เช่น คาสัง่ ตัวแปร
ค่าคงที่ เป็ นต ้น รวมถึงการขจัด ส่วน
หมายเหตุ(Comment) ช่องว่างขาว
(White space) เช่น blank, tab และ
้
้
new line เป็ นต ้น ผลของขันตอนนี
จะ
http://www.thaiall.com/programming
Page: 6
ซินแทกซ ์ อนาไลเซอร ์ (Syntax
Analyzer)(2/5)
่
้
่
ขันตอนทีสอง ทาหน้าที
ตรวจสอบความสัมพันธ ์ การ
จัดเรียง และความถูกต ้องของแต่
่ วธิ ี
ละคา แต่ละประโยค ซึงมี
ตรวจสอบหลายวิธ ี เช่น
ตรวจสอบ parse tree ว่ามี
่
http://www.thaiall.com/programming
Page: 7
ซีแมนติก อนาไลเซอร ์ (Semantic
Analyzer)(3/5)
้
่
ขันตอนทีสาม
ทาหน้าที่
ตรวจสอบความหมายของภาษา และ
่ ผ่
่ านการ
สร ้างรหัสของชุดคาสังที
ตรวจสอบความถูกต ้องของโครงสร ้าง
้
่
แล ้ว ให ้อยูใ่ นรูปแบบ หรือขันตอนที
่ ซึงเป็
่ น
ใกล ้เคียงกับภาษาเครือง
ภาษากลางทีง่่ ายต่อการปร ับปรุง หรือ
่ อไป
นาไปแปลงเป็ นภาษาเครืองต่
http://www.thaiall.com/programming
Page: 8
โค ้ด ออฟติไมเซอร ์ (Code
Optimizer)(4/5)
้
่ ่ ทาหน้าที่ ปร ับปรุง
ขันตอนทีสี
่ ้ให ้มีประสิทธิภาพในการ
code ทีได
ทางาน ใน compiler บางตัวอย่างไม่
้ั
้ หรือมีขนตอนนี
้ั
้ ที่
มีขนตอนนี
้ ได ้
ละเอียดกว่านี ก็
http://www.thaiall.com/programming
Page: 9
โค ้ด เจนเนอเรเตอร ์ (Code
Generator)
(5/5)
่
้
่
ขันตอนทีห้า ทาหน้าที
่
่
เปลียนรหัสทีได ้ให ้เป็ น
ภาษาแอสเซมบลี หรือ
่ ซึง่ code ทีได
่ ้มี
ภาษาเครือง
้
่ ที่
ลักษณะขึนอยู
่กบั เครือง
ให ้บริการ หน่ วยความจา และ
่
http://www.thaiall.com/programming
Page: 10
ทฤษฎีของการออกแบบ และ การแสดงแบบ
ซอฟต
์แวร
์
•การพิมพ ์โปรแกรมต้นฉบับ (Source
listing)
•ผังงาน (Flowchart)
•ผังงานโปรแกรมโครงสร ้าง (Structured
flowchart)
•ผังงานแบบ Nassi-Shneiderman
•ผังงานแบบ HIPO (Hierarchy plus
input-process-output)
•ผังงานแจ็คสัน (Jackson Diagram)
•ผังงานแบบวาร ์นิ เอร ์-ออร ์ (Warnier-Orr
http://www.thaiall.com/programming
Page: 11
Flowchart Diagram (1/2)
ผังงาน (Flowchart) คือ รูปภาพ
(Image) หรือสัญลักษณ์(Symbol) ที่
้
ใช ้เขียนแทนขันตอน
คาอธิบาย
่ ้ในอัลกอริทม
ข ้อความ หรือคาพูด ทีใช
ึ
(Algorithm) เพราะการนาเสนอ
้
ขันตอนของงานให
้เข ้าใจตรงกัน ระหว่าง
่
ผูเ้ กียวข
้อง ด ้วยคาพูด หรือข ้อความ ทา
่ ้รูปภาพ หรือ
ข ้อมู
http://www.thaiall.com/flowchart/
ไดลจาก
้ยากกว่
าเมือใช
http://www.thaiall.com/programming
Page: 12
Flowchart
Diagram (2/2)
ข ้อมูลจาก http://www.thaiall.com/flowchart
ข ้อมูลจาก http://www.yourdon.com/strucanalysis/wiki/index
http://www.thaiall.com/programming
Page: 13
HIPO Diagram (1/2)
HIPO (Hierarchy plus InputProcess-Output) ถูกพัฒนาโดยบริษท
ั IBM
่ 2517 เพือเป็
่ นเครืองมื
่ อทีช่
่ วยในการ
เมือ
ออกแบบ และแสดงแบบซอฟต ์แวร ์ โดยใช ้ผังงาน
่ งงานสาหร ับอธิบายส่วนนา
แบบเดิม แต่เพิมผั
ข ้อมูลเข ้า ส่วนประมวลผล และส่วนส่งออก
ซึง่ HIPO ประกอบด ้วยผังงาน 3 ประเภท
คือ
1) ผังงานลาดับความสาคัญของกิจกรรม
(Hierarchy Diagram หรือ Visual Table of
http://www.thaiall.com/programming
Page: 14
HIPO Diagram (2/2)
ข ้อมูลจาก http://www.shk-dplc.com/cfo/articles/litigate.htm
ข ้อมูลจาก http://www.yourdon.com/strucanalysis/wiki/index
http://www.thaiall.com/programming
Page: 15
Nassi-Shneiderman diagram
(NSD) (1/3)
A Nassi-Shneiderman
diagram (or NSD) is a graphical
design representation for
structured programming.
Developed in 1972 by Isaac Nassi
and Ben Shneiderman, these
ข ้อมู
ลจาก http://en.wikipedia.org/wiki/Nassi-Shneiderman_
diagrams
are also called
ข ้อมูลจาก http://www.cs.umd.edu/hcil/members/bshneiderm
structograms, as they show a
http://www.thaiall.com/programming
Page: 16
Nassi-Shneiderman diagram
(NSD) (2/3)
้
ไดอะแกรมนี แสดงการโปรแกรม
โครงสร ้างอย่างเป็ นระเบียบด ้วย
่ ยม
่ และใช ้เส ้นทะแยงแยกซ ้าย
สีเหลี
ขวาสาหร ับการตัดสินใจ ใช ้บล็อก
้ มการทาซาทั
้ งแบบ
้
ตามแนวตังคุ
้
while และ repeat โดยทังหมดอยู
่
ข ้อมูลจาก http://en.wikipedia.org/wiki/Nassi-Shneiderman_
่ ยมเดี
่
ในกรอบสี
เหลี
ย
วกั
น
ข ้อมูลจาก http://www.cs.umd.edu/hcil/members/bshneiderm
http://www.thaiall.com/programming
Page: 17
Nassi-Shneiderman diagram
(NSD) (3/3)
ข ้อมูลจาก http://www.yourdon.com/strucanalysis/wiki/index
http://www.thaiall.com/programming
Page: 18
Jackson Diagram (1/3)
Jackson Structured Programming (JSP) is
a method for structured programming based
on correspondences between data stream
structure and program structure. The method
is closely related in concept to creating a
parser for a regular expression that describes
the data stream structure, but tries to build a
program structure that matches more than
one data stream and provides guidance and
techniques to compensate the limited
lookahead and the clashes between the
structures of the different data streams.
JSP
was originally developed in the 1970s by IT
consultant
Michael A. Jackson and
ข ้อมูลจาก http://www.smartdraw.com/resources/tutorials/jackson-sys
documented
in his 1975 book Principles of
ข ้อมูลจาก http://en.wikipedia.org/wiki/Jackson_Structured_Programm
Program
Design. Jackson's aim was to improve
http://www.thaiall.com/programming
Page: 19
Jackson Diagram (2/3)
้
มพันธ ์ของ
ไดอะแกรมนี แสดงความสั
ข ้อมูล (Entity) และกิจกรรม (Action) ว่า
แต่ละตารางมีกจิ กรรมอะไรบ ้าง มีสญ
ั ลักษณ์
Circle เล็กมุมบนขวาแสดงกิจกรรมเลือก
สัญลักษณ์ asterisk แสดงการทาซา้ ส่วน
โครงสร ้างไดอะแรกคล ้ายกับ Organization
ข ้อมูลจาก http://www.smartdraw.com/resources/tutorials/jackson-sys
Chart
จากบนลงล่าง
ข ้อมูลจาก http://en.wikipedia.org/wiki/Jackson_Structured_Programm
http://www.thaiall.com/programming
Page: 20
Jackson Diagram (3/3)
ข ้อมูลจาก http://www.smartdraw.com/resources/tutorials/jackson-sys
http://www.thaiall.com/programming
Page: 21
Warnier-orr Diagram (1/2)
Warnier/Orr diagrams are a kind of
hierarchical flowchart that allows us to
describe the organization of data and
procedures. There are four basic constructs
used on Warnier/Orr diagrams: hierarchy,
sequence, repetition, and alternation. There
are also two slightly more advanced concepts
that are occasionally needed: concurrency and
recursion. Each of these six diagramming
constructs are illustrated in the sections that
follow.
http://www.thaiall.com/programming
Page: 22
Warnier-orr Diagram (2/2)
1. Hierarchy is the most fundamental of all of the Warnier/Orr constructs. It is
simply a nested group of sets and subsets shown as a set of nested brackets.
2. Sequence is the simplest structure to show on a Warnier/Orr diagram. Within
one level of hierarchy, the features listed are shown in the order in which they
occur.
3. Repetition is the representation of a classic "loop" in programming terms. It
occurs whenever the same set of data occurs over and over again (for a data
structure) or whenever the same group of actions is to occur over and over
again (for a processing structure).
4. Alternation or selection, is the traditional "decision" process whereby a
determination is made to execute one process or another.
5. Concurrency is one of the two advanced constructs used in the
methodology. It is used whenever sequence is unimportant.
6. Recursion is the least used of the constructs. It is used to indicate that a set
contains an earlier or a less ordered version of itself
http://www.thaiall.com/programming
Page: 23
Structure Chart
แผนผังโครงสร ้าง (Structure Chart) หมายถึง
่ อทีอธิ
่ บายถึงการแบ่งการทางานของระบบ
เป็ นเครืองมื
ออกเป็ นส่วนย่อย หรือโมดูล โดยแสดงโมดูลเป็ นลาดับ
้
้
ขันตามการเรี
ยกใช ้ข ้อมูล พร ้อมทังแสดงถึ
ง
ความสัมพันธ ์ระหว่างโมดูล
http://www.thaiall.com/programming
Page: 24
Decision Tree
Decision tables are a precise yet
compact way to model complicated
logic. Decision tables, like if-then-else
and switch-case statements, associate
conditions with actions to perform. But,
unlike the control structures found in
traditional programming languages,
decision tables can associate many
independent conditions
with several actions in
http://www.thaiall.com/programming
Page: 25
USE CASE in UML
Use Case Diagram เป็ น
Diagram
่ าหน้าที่ Capture
ทีท
requirement
http://www.thaiall.com/programming
Page: 26
Compiler & Interpreter
่ ละ
Interpreter จะแปลคาสังที
่
บรรทัด และทางานไปทีละบรรทัด เมือพบ
ข ้อผิดพลาดก็จะหยุดการทางานทันที
่ างานแบบนี คื
้ อ GWตัวอย่างภาษาทีท
Basic
่ งหมด
้
Compiler จะแปลคาสังทั
และ
สร ้างเป็ น Object File หากพบ
http://www.thaiall.com/programming
Page: 27
การออกแบบ และสร ้างลักษณะต่าง
่ ๆบ
ของภาษา
•แนวคิดเกียวกั
ภาษาฟอร ์มัล
•รูปแบบ และคุณลักษณะทางไวยากรณ์
้ ้น
เบืองต
•ชนิ ด และโครงสร ้างของข ้อมูล
•โครงสร ้างของการควบคุม และการ
่
่
เคลือนที
ของข
้อมูล
•การพิจารณาเวลาในการประมวลผล
http://www.thaiall.com/programming
Page: 28
่
ประเภทของภาษาชุดคาสัง
•แบบกาหนดกระบวนการ
(Procedural
Programming)
•แบบไม่กาหนดกระบวนการ
(UnProcedural
ข ้อมูลจาก http://en.wikipedia.org/wiki/Procedural_program
ข ้อมูลจาก http://en.wikipedia.org/wiki/Unstructured_progra
http://www.thaiall.com/programming
Page: 29
่
ภาษาชุดคาสังแบบกาหนด
กระบวนการ
Procedural programming is sometimes
used as a synonym for imperative
programming (specifying the steps the
program must take to reach the desired
state), but can also refer (as in this article)
to a programming paradigm based upon
the concept of the procedure call.
Procedures, also known as routines,
subroutines, methods, or functions (not to
be confused with mathematical functions,
but similar to those used in functional
programming) simply contain a series of
computational
steps to be carried out. Any
ข ้อมูลจาก http://en.wikipedia.org/wiki/Procedural_program
given procedure might be called at any
http://www.thaiall.com/programming
Page: 30
่
ภาษาชุดคาสังแบบไม่กาหนด
UnProcedural กระบวนการ
programming or
unstructured programming is a
programming paradigm where all code
is contained in a single continuous
block. This is contrary to structured
programming, where programmatic
tasks are split into smaller sections
(known as functions or subroutines)
that can be called whenever they are
ข
้อมูลจาก http://en.wikipedia.org/wiki/Unstructured_progra
required.
Unstructured programming
http://www.thaiall.com/programming
Page: 31
โครงสร ้างภาษาแบบต่าง ๆ
•แบบโครงสร ้างบล๊อก (Block
Structure)
•แบบมอดูลาร ์ (Module
Structure)
ข ้อมูลจาก http://en.wikipedia.org/wiki/Statement_block
•แบบเชิ
งวัตถุ (Object-Oriented
ข ้อมูลจาก http://en.wikipedia.org/wiki/Module_%28program
ข ้อมูลจาก http://en.wikipedia.org/wiki/Object-oriented_prog
Structure)
http://www.thaiall.com/programming
Page: 32
โครงสร ้างภาษาแบบโครงสร ้างบล๊อก (Block
Structure)
A statement block (or code
block) is a section of code which is
grouped together, much like a
paragraph; such blocks consist of
one, or more, statements. Statement
blocks help make code more
statement blocks are enclosed by braces
readable by breaking up programs
{ ... }
into
logical
work units.
ข ้อมูลจาก
http://en.wikipedia.org/wiki/Statement_block
http://www.thaiall.com/programming
Page: 33
โครงสร ้างภาษาแบบมอดูลาร ์ (Module
Structure)
A module is a software entity that
groups a set of (typically cohesive)
subprograms and data structures.
Modules are units that can be compiled
separately, which makes them reusable
and allows multiple programmers to
work on different modules
simultaneously. Modules also promote
ข
้อมูลจาก http://en.wikipedia.org/wiki/Module_%28program
modularity
and encapsulation (i.e.
http://www.thaiall.com/programming
Page: 34
โครงสร ้างภาษาแบบเชิงวัตถุ (ObjectOriented Structure)
Object-oriented programming (OOP)
is a programming paradigm that uses
"objects" to design applications and
computer programs. It can use several
techniques from previously established
paradigms, including inheritance,
modularity, polymorphism, and
encapsulation. It was not commonly used
in mainstream software application
ข
้อมูลจาก http://en.wikipedia.org/wiki/Object-oriented_pro
development
until the 1990s, though
http://www.thaiall.com/programming
Page: 35
แนวคิดภาษาโปรแกรมเชิงวัตถุ
1. การปกป้ อง (Encapsulation)
2. การสืบทอด (Inheritance)
3. หลายรูป (Polymorphism)
- ต่างตัวแปร (Overloading)
- เขียนทับ (Overriding)
http://www.thaiall.com/programming
Page: 36