120 likes | 276 Views
This course, offered by the School of Information Communication Technology at the University of Phayao, aims to deepen understanding of design patterns in software engineering. Students will explore the definition, origins, and significance of design patterns, categorized into three groups: Creational, Structural, and Behavioral. The course references the influential book "Design Patterns: Elements of Reusable Object-Oriented Software" by the Gang of Four. Through practical examples like the SimUDuck application, students will learn to apply design patterns to solve real-world programming challenges effectively.
E N D
Design pattern WATTANAPONGSUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO
จุดประสงค์การเรียนรู้จุดประสงค์การเรียนรู้ • เข้าใจถึงความหมายของแบบรูปการออกแบบ • เข้าใจถึงที่มาและความสำคัญของแบบรูปการออกแบบ • จำแนกแบบรูปการออกแบบทั้ง 3 ประเภทได้
Design pattern ถูกพัฒนาขึ้นมาจากกลุ่มของคนสี่คน(Gang of four)โดยถูกเรียบเรียงในหนังสือ เรื่อง “Design Pattern : Elements of Reusable Object-Oriented Software” (Gamma, et. al. 1995) • จุดประสงค์เพื่อช่วยแก้ปัญหาในด้านการเขียนโปรแกรมเชิงวัตถุ โดยการสร้างรูปแบบของความสัมพันธ์ของคลาส มีทั้งหมด 23 รูปแบบ โดยสามารถแบ่งกลุ่มเป็น 3 กลุ่มได้แก่ 1. Creational ตามการสร้างวัตถุหรือคลาส 2. Structuralตามส่วนประกอบของวัตถุหรือคลาส 3. Behavioralตามความสัมพันธ์ระหว่างวัตถุหรือคลาส
Simuduck app Manc: simulation game, SimUDuck. The game can show : • duck species swimming • making quacking sound Initial designer of the system : OO techniques one Duck superclass was inherited to other duck
Simuduck app In the last year, company : under increasing pressure from competitors After brainstorming : big innovation
Simuduck app The Answer : Flying duck executive : flying duck can blow away from duck competitors
Simuduck app • But something went horribly wrong... • All of ducks can fly and quack
Simuduck app • Solve : Override method • RubberDuck quack(){ do nothing… } • DecoyDuck quack(){ squeak } display() fly(){ do nothing… } display() fly(){ do nothing… }
Simuduck app • inheritance not solved : executive want to update product every 6 months • what’s the problem : some ducks can fly, quack, squeak,… • interface class • what do you thing about design?
Simuduck app • What would you do if you were Manc?
Strategy Pattern Simuduck app