วันศุกร์ที่ 12 ธันวาคม พ.ศ. 2557

Flowchart (รูปแบบการเขียนผังงาน)

1. ผังงานแบบลำดับ

ผังงานการชงกาแฟ 
ผังงานแบบลำดับ (sequential flowchart) เป็นผังงานที่มีโครงสร้างการกระทำตามลำดับกิจกรรมก่อนหลังที่เรียงเป็นลำดับต่อเนื่องกันไปเรื่อย ๆ การเขียนผังงานแบบลำดับจะเป็นโครงสร้างที่ง่ายที่สุดเหมาะสำหรับงานที่ไม่มีความซับซ้อน ไม่มีการตรวจสอบเงื่อนไข และไม่ต้องการทำงานซ้ำ ๆ แต่ในบางครั้งผังงานแบบลำดับมักจะไปรวมอยู่ในผังงานแบบเลือก และแบบทำซ้ำในกรณีที่มีกิจกรรมทำงานต่อเนื่องกันไปเรื่อย ๆ โดยส่วนมากจะเป็นการจัดวาง กิจกรรมจากบนลงล่าง และจากซ้ายไปขวา

2. ผังงานแบบทางเลือก (แบบตัดสินใจ)

แผนงานการเดินทางมาโรงเรียน

การทำงานแบบทางเลือก (Selection) หรือเรียกอีกอย่างหนึ่งว่า การทำงานแบบตัดสินใจ (Decision) นั่นคือเราสามารถให้โปรแกรมเลือกทำงานอย่างใดอย่างหนึ่งได้ โดยใช้เงื่อนไขเป็นตัวกำหนดการทำงานตามคำสั่ง โดยทั่วไปโปรแกรมจะกำหนดเอาไว้ว่าถ้าเงื่อนไขเป็นจริงโปรแกรมจะไปทำงานอย่างหนึ่ง แต่ถ้าเงื่อนไขเป็นเท็จโปรแกรมก็จะไปทำงานอีกอย่างหนึ่ง นั่นก็หมายความว่า โปรแกรมจะเลือกทำงานทิศทางใดทิศทางหนึ่งเท่านั้น เช่น เมื่อเราขับขี่รถไปถึงทางสามแยก เราจะต้องตัดสินใจไปทางใดทางหนึ่ง ไม่สามารถวิ่งไปทั้งสองทางได้ในเวลาเดียวกัน

3. ผังงานแบบวนซ้ำ

แผนงานการออกจากบ้าน
ลักษณะของขั้นตอนวิธีการทำงาน นอกจากขั้นตอนวิธีการทำงานแบบลำดับแลละขั้นตอนวิธีแบบเลือกทำแล้ว ยังมีลักษณะการทำงานของขั้นตอนวิธีอีกลักษณะหนึ่ง คือ ขั้นตอนวิธีการทำงานแบบทำซ้ำ ขั้นตอนวิธีการทำงานแบบทำซ้ำใช้สำหรับกรณีที่ต้องการทำกระบวนการต่าง ๆ ซ้ำกันหลายครั้ง โดยมีการตรวจสอบเงื่อนไขสำหรับการตัดสินใจ เพื่อเข้าสู่ขั้นตอนของการทำซ้ำ หรือออกจากขั้นตอนของการทำซ้ำ การเขียนขั้นตอนวิธีสำหรับการทำงานแบบทำซ้ำ ได้รับการพัฒนามาจากโครงสร้างผังงานการทำซ้ำ
            วิธีการเขียนอธิบายขั้นตอนวิธีการทำงานและรหัสเทียมสำหรับโครงสร้างผังงานแบบทำซ้ำ มีวิธีการเขียนต่างไปจากการทำงานแบบลำดับและแบบเลือกทำ แต่บางครั้งการทำงานของขั้นตอนวิธีการแก้ปัญหาที่มีขั้นตอนวิธีการทำงานแบบทำซ้ำ อาจประกอบด้วยขั้นตอนวิธีการทำงานแบบลำดับหรือขั้นตอนวิธีการทำงานแบบเลือกทำร่วมอยู่ในขั้นตอนวิธีการทำงาน ดังนั้นการเขียนอธิบายขั้นตอนวิธีการทำงานแบบทำซ้ำ จะใช้การเขียนอธิบายขั้นตอน สำหรับขั้นตอนวิธีการทำงานในลักษณะนั้น

E N G L I S H E N G L I S H E N G L I S H E N G L I S H E N G L I S H E N G L I S H E N G L I S H E N G L I S H E N G L I S H 

1. Sequence Flowchart

Flowchart for Drinking Coffee

The flowchart above demonstrates a sequence of steps. The reader would start at the Start shape and follow the arrows from one rectangle to the other, finishing at the End shape.  A sequence is the simplest flowcharting construction. You do each step in order. 
If your charts are all sequences, then you probably don't need to draw a flowchart. You can type a simple list using your word processor. The power of a flowchart becomes evident when you include decisions and loops.  
RFFlow allows you to number your shapes if you wish. Run RFFlow and click on Tools, Number Shapes, and put a check mark in Enable numbers for the entire chart. You can also choose to have a number or not in each individual shape and you can quickly renumber your chart at any time.

2. Decision Flowchart

Flowchart for taking to school

This structure is called a decision, "If Then.. Else" or a conditional. A question is asked in the decision shape. Depending on the answer the control follows either of two paths. In the chart above, if the temperature is going to be less than freezing (32 degrees Fahrenheit) the tomatoes should be covered. Most RFFlow stencils include the words "Yes" and "No" so you can just drag them onto your chart. "True" and "False" are also included in most of the flowcharting stencils.

3. Loop or Iteration Flowchart

Flowchart for going outside

This structure allows you to repeat a task over and over. The red chart above on the left does the task and repeats doing the task until the condition is true.  The green chart on the right checks the condition first and does the task while the condition is true. It is not important that you remember whether the loop is a "Do While" or "Repeat Until" loop, only that you can check the condition at the start of the loop or at the end. You can also have the conditions reversed and your loop is still a structured design loop. A slight variation of the above is the "For each...do the following" . 

T H X T H X T H X T H X T H X T H X T H X T H X T H X T H XT H X T H X T H X T H X T H X T H X T H X T H X T H X T H X T H X T H X