Tech. Dept. @Tungs' Taichung MetroHarbor Hospital • Tech Lead of Intelligent Healthcare Application • Community • Co-organizer of Taichung.py since June 2014 • Organizer of the Agile Taichung, 2014~2018 • Host of Agile Tour Taichung, 2015~2018
communication • Reuse solutions : do not have to reinvent solutions for commonly recurring problems • Establish common terminology : provide a common point of reference during the analysis and design phase of a project • Design patterns give a higher perspective on analysis and design • This frees you from the tyranny of dealing with the details too early Source: Design Patterns Explained: A New Perspective on Object-Oriented Design, 2nd ed.
• Solution, implementation guidelines • Participants and collaborators • Positive and negative consequences Pattern descriptions are often independent of programming language or implementation details
• Building by adding distinctions • One pattern at a time • Encapsulate variations in classes Source: Design Patterns Explained: A New Perspective on Object-Oriented Design, 2nd ed.
and Health Examination Record Form 勞工一般/特殊特殊體格及健康檢查紀錄 • Occupational Safety and Health Administration, Ministry of Labor (勞 動部職業安全衛生署) • https://www.osha.gov.tw/1106/29647/1141/13440/ • There are total 33 forms in this case • In fact, there are thousands of forms in a hospital
does not define a new type; • it merely bundles methods for reuse • Make Mixins Explicit by Naming • named with a ...Mixin suffix • e.g. JsonMixin in case study
16 out of the 23 patterns in the original Design Patterns book become either “invisible or simpler” in a dynamic language (slide 9) • “Design Patterns in Dynamic Languages” (1996) Source: http://norvig.com/design-patterns/design-patterns.pdf
• A “first-class object” as a program entity that can be: • created at runtime; • assigned to a variable or element in a data structure; • passed as an argument to a function; • returned as the result of a function. Source: Fluent Python, 2nd edition
single copy of each module • subsequent imports of the same name keep returning the same module object • Official Python FAQ[1]: using a module is also the basis for implementing the Singleton design pattern, for the same reason. [1] https://docs.python.org/3/faq/programming.html#how-do-i-share-global-variables-across-modules
problem • Recur • Have a name Why • Reuse solutions • Establish common terminology • Give a higher perspective on design How • Context first • One pattern at a time • Encapsulate variations