มาใช้ diagram อธิบายการทำงานของระบบต่าง ๆ กันเถอะ

มาใช้ diagram อธิบายการทำงานของระบบต่าง ๆ กันเถอะ

12 July 2022

หากเราจะอธิบายการทำงานของระบบบางอย่างให้คนอื่นเข้าใจได้ง่าย ๆ คงหนีไม่พ้นการทำ diagram ที่สามารถแสดงให้เห็นถึงกระบวนการของระบบ ขั้นตอนการทำงาน หรือเห็นแต่ละกลุ่มที่มีหน้าที่ในระบบนั้น ๆ

diagram ที่เราจะนำมาพูดถึงในวันนี้คือ sequence diagram และ activity diagram ทั้งสองเป็น diagram ที่มีวัตถุประสงค์ในการแสดงพฤติกรรมการทำงานของระบบ สามารถเห็นภาพรวมของระบบหรือกระบวนการของงานได้ง่ายขึ้น ตัวอย่างระบบการทำงานที่สามารถใช้ diagram เช่น การทำงาน/การคำนวณค่าบางอย่าง หรือ ระบบที่มีการเรียกใช้งานระบบส่วนอื่น ๆ เพื่อทำงานอะไรบางอย่าง

sequence diagram และ activity diagram ทั้งสองอย่างนี้เป็นส่วนหนึ่งของ Unified Modeling Language (UML) คือเป็นภาษาภาพที่มีมาตรฐานกลางที่ใช้ในการอธิบายระบบ เพื่อให้เกิดความเข้าใจแก่ผู้ออกแบบกับโปรแกรมเมอร์ หรือฝั่งที่เกี่ยวกับ business ส่วนใหญ่จะถูกใช้ในบริบทเกี่ยวกับการพัฒนาซอฟต์แวร์ แต่ก็สามารถใช้อธิบายระบบต่าง ๆ เพื่อให้คนทำงานทั่วไปเข้าใจได้เช่นกัน

ตัวอย่าง activity diagram (ซ้าย) และ sequence diagram (ขวา)

Activity diagram

เป็น diagram ที่แสดงถึง workflow กิจกรรมของระบบ แสดงขั้นตอนการทำงานหนึ่งไปสู่อีกอันหนึ่ง โดยวิธีการเขียนจะต้องมีจุดเริ่มต้น-จุดสิ้นสุด และมีกิจกรรมต่าง ๆ ที่เกิดขึ้นระหว่างจุดเริ่มต้นกับจุดสิ้นสุด

สัญลักษณ์พื้นฐาน

สัญลักษณ์ชื่อคำอธิบาย
Initial State / Start Pointจุดเริ่มต้น
Activity or Action Stateกิจกรรม
Object FlowGuardsการไหลของกิจกรรม
Guardsกรณีมีเงื่อนไข
Synchronizationกรณีมีการทำกิจกรรมพร้อม ๆ กัน
Final State / End Pointจุดสิ้นสุด

ตัวอย่าง Activity diagram

Activity diagram – การกรอกข้อมูลลงทะเบียนเข้าร่วมโครงการ

ทั้งนี้ activity diagram สามารถแบ่งหมวดหมู่ของกิจกรรมได้ด้วยการเขียนเป็นแบบ Swimlanes ที่จะจัดกิจกรรมแต่ละอันตามหมวดหมู่ หรือผู้ที่รับผิดชอบกิจกรรมนั้น เพื่อให้เห็นภาพของระบบได้ง่ายขึ้น เช่น การบริการลูกค้าของร้านอาหาร จะแบ่งเป็น 3 ส่วน ได้แก่ ลูกค้า พนักงาน พ่อครัว

ตัวอย่าง activity diagram แบบ Swimlanes

Activity diagram แบบ Swimlanes – การบริการลูกค้าของร้านอาหาร

Sequence diagram

Sequence diagram ใช้แสดงถึงการปฏิสัมพันธ์กันในแต่ละส่วน ว่ามีการส่งข้อความหรือข้อมูลอะไรถึงกัน โดยแสดงตามลำดับของเวลา

สัญลักษณ์พื้นฐาน

สัญลักษณ์ชื่อคำอธิบาย
Actorผู้กระทำต่อระบบ
Objectอ็อบเจกต์ที่ต้องทำกิจกรรม
Lifelineเส้นการมีอยู่ของอ็อบเจกต์
Focus of Control / Activationแสดงถึงจุดเริ่มต้นและจุดสิ้นสุดของช่วงการทำกิจกรรม
Messageคำสั่ง หรือฟังก์ชันการทำงานที่มีการส่งไป
Callback / Self Delegationคำสั่ง หรือฟังก์ชันการทำงานที่เรียกภายในตัวเอง

ตัวอย่าง sequence diagram

Sequence diagram – ระบบการซื้อของออนไลน์ผ่านเว็บไซต์

โดยทั้ง 2 diagram นี้สามารถทำออนไลน์ผ่านเว็บบราวเซอร์ได้เลย ตัวอย่างที่มีให้ใช้งานได้ฟรี เช่น diagrams.net, visual-paradigm online ที่สามารถทำได้ทั้ง activity diagram และ sequence diagram และผู้เขียนขอแนะนำเว็บไซต์ทำ sequence diagram แบบ codebase (ทำ diagram ด้วยการเขียนเป็นโค้ด) ทำให้ไม่ต้องเสียเวลาจัดรูปแบบ ปรับขนาดกล่อง ข้อความต่าง ๆ แค่พิมพ์ให้ถูกลำดับ ถูกไวยากรณ์ของเว็บไซต์ที่เราใช้งาน เช่น SequenceDiagram.org, WebSequenceDiagrams

การเลือกใช้งานระหว่าง 2 diagram นี้จะขึ้นอยู่กับว่าเราต้องการโฟกัสที่จุดไหน หากต้องการเห็น workflow ของกิจกรรมที่เกิดขึ้นภายในระบบก็ให้เลือก activity diagram แต่หากต้องการโฟกัสที่ลำดับขั้นการทำงานของระบบ โดยเน้นที่ข้อความหรือคำสั่งที่มีการแลกเปลี่ยนระหว่างอ็อบเจกต์ก็ให้เลือก sequence diagram

เนื้อหาโดย วริศ หลิ่มโตประเสริฐ
ตรวจทานและปรับปรุงโดย อิสระพงศ์ เอกสินชล

Data Engineer at Big Data Institute (Public Organization), BDI

แบ่งปันบทความ

กลุ่มเนื้อหา

แท็กยอดนิยม

แจ้งเรื่องที่อยากอ่าน

คุณสามารถแจ้งเรื่องที่อยากอ่านให้เราทราบได้ !
และเราจะนำไปพัฒนาบทความให้มีเนื้อหาที่น่าสนใจมากขึ้น

PDPA Icon

We use cookies to optimize your browsing experience and improve our website’s performance. Learn more at our Privacy Policy and adjust your cookie settings at Settings

Privacy Preferences

You can choose your cookie settings by turning on/off each type of cookie as needed, except for necessary cookies.

Accept all
Manage Consent Preferences
  • Strictly Necessary Cookies
    Always Active

    This type of cookie is essential for providing services on the website of the Personal Data Protection Committee Office, allowing you to access various parts of the site. It also helps remember information you have previously provided through the website. Disabling this type of cookie will result in your inability to use key services of the Personal Data Protection Committee Office that require cookies to function.
    Cookies Details

  • Performance Cookies

    This type of cookie helps the Big Data Institute (Public Organization) understand user interactions with its website services, including which pages or areas of the site are most popular, as well as analyze other related data. The Big Data Institute (Public Organization) also uses this information to improve website performance and gain a better understanding of user behavior. Although the data collected by these cookies is non-identifiable and used solely for statistical analysis, disabling them will prevent the Big Data Institute (Public Organization) from knowing the number of website visitors and from evaluating the quality of its services.

  • Functional Cookies

    This type of cookie enables the Big Data Institute (Public Organization)’s website to remember the choices you have made and deliver enhanced features and content tailored to your usage. For example, it can remember your username or changes you have made to font sizes or other customizable settings on the page. Disabling these cookies may result in the website not functioning properly.

  • Targeting Cookies

    "This type of cookie helps the Big Data Institute (Public Organization) understand user interactions with its website services, including which pages or areas of the site are most popular, as well as analyze other related data. The Big Data Institute (Public Organization) also uses this information to improve website performance and gain a better understanding of user behavior. Although the data collected by these cookies is non-identifiable and used solely for statistical analysis, disabling them will prevent the Big Data Institute (Public Organization) from knowing the number of website visitors and from evaluating the quality of its services.

Save settings
This site is registered on wpml.org as a development site. Switch to a production site key to remove this banner.