patterns -structural patterns wattanapon g suttapak software engineering, school of information...
TRANSCRIPT
1
PATTERNS-STRUCTURAL
PATTERNS
WATTANAPONG SUTTAPAKSoftware Engineering, School of Information Communication Technology,University of PHAYAO
2
จุ�ดประสงค์การเร�ยนร� �
เข้�าใจุร�ปแบบข้องแบบร�ปการออกแบบทั้��ง 8 ประเภทั้
ประย�กต์ใช้�แบบร�ปการออกแบบทั้��ง 8 ประเภทั้ได�
STRUCTURAL PATTERNS• These patterns concern class and object composition
•Concept of inheritance is used to compose interfaces and define ways to compose objects to obtain new functionalities 1. Adapter2. Bridge3. Filter(new)4. Composite
5. Decorator6. Façade7. Flyweight8. Proxy
ADAPTER PATTERN• works as a bridge between two incompatible interfaces.
• A real life example, card reader(adapter) read memory(object) to laptop(object)
10
BRIDGE PATTERN•decouple an abstraction from its implementation
•the two can vary independently.
•decouples implementation class and abstract class by providing a bridge structure between them.
•This pattern involves an interface as a bridge
•functionality of concrete classes independent from interface implementer classes.
•demonstrating use of Bridge pattern via following example in which a circle can be drawn in different colors using same abstract class method but different bridge implementer classes.
11
BRIDGE PATTERN• Shape Square ,Triangle, …
• check duplicate pattern
• Color Red, Blue, …
• Shape and Color
18
FILTER PATTERN•filter a set of objects
•using different criteria
•combining multiple criteria to obtain single criteria.
33
FACADE PATTERN hiding the complexities of the system
the client can access the system via interface
36
FLYWEIGHT PATTERN primary pattern for reduce the number of objects created
decrease memory footprint and increase performance
demonstrate this pattern by drawing 20 circle of different locations but we'll creating only 5 objects. Only 5 colors are available so color property is used to check already existing Circle objects.
41
PROXY PATTERN a class represents functionality of another class
In Proxy pattern, we create object having original object to interface its functionality to outer world.