70 likes | 215 Views
Structural Patterns. Class patterns – inheritance Object patterns – composition - you can change the composed class at run-time. class UsefulClass useful_operation() Class NicksClass UsefulClass myUsefulClass; nicks_operation() { myUsefulClass.useful_operation() }.
E N D
Structural Patterns Class patterns – inheritance Object patterns – composition - you can change the composed class at run-time
class UsefulClass useful_operation() Class NicksClass UsefulClass myUsefulClass; nicks_operation() { myUsefulClass.useful_operation() }
OtherClass Request()
Bridge Abstraction – the set of operations a class or class hierarchy must support Implementation – Different ways of performing those operations
DataImp UpdateData changeGrade(name…) changeGrade(name…) SQLupdate PickleUpdate changeGrade(name…) { Send SQL update cmn To database changeGrade(name…) { Read in data, change it, Write to file
DataImp UpdateData changeGrade(name…) changeGrade(name…) ? ? SQLupdate PickleUpdate changeGrade(name…) { Send SQL update cmn To database changeGrade(name…) { Read in data, change it, Write to file