TDDB84: Lecture 09. SOLID, Language design, Summary. fredag 11 oktober 13

Size: px
Start display at page:

Download "TDDB84: Lecture 09. SOLID, Language design, Summary. fredag 11 oktober 13"

Transcription

1 TDDB84: Lecture 09 SOLID, Language design, Summary

2 SOLID Single responsibility principle Open/closed principle Liskov substitution principle Interface segregation principle Depency inversion principle

3 SOLID Single responsibility principle Open/closed principle Liskov substitution principle Interface segregation principle Depency inversion principle

4 Single responsibility Encapsulate what varies Program to an interface, not to an implementation Favor composition over inheritance Classes should be open for extension but closed for modification Don t call us, we ll call you Dep on abstractions, do not dep on concrete classes Classes should only have one reason to change Strive for loosely-coupled design

5 Single responsibility Encapsulate what varies Program to an interface, not to an implementation Favor composition over inheritance Classes should be open for extension but closed for modification Don t call us, we ll call you Dep on abstractions, do not dep on concrete classes Classes should only have one reason to change Strive for loosely-coupled design

6 Single responsibility Encapsulate what varies Program to an interface, not to an implementation Favor composition over inheritance Classes should be open for extension but closed for modification Don t call us, we ll call you Dep on abstractions, do not dep on concrete classes Classes should only have one reason to change Strive for loosely-coupled design

7 Open/closed Encapsulate what varies Program to an interface, not to an implementation Favor composition over inheritance Classes should be open for extension but closed for modification Don t call us, we ll call you Dep on abstractions, do not dep on concrete classes Classes should only have one reason to change Strive for loosely-coupled design

8 Open/closed Encapsulate what varies Program to an interface, not to an implementation Favor composition over inheritance Classes should be open for extension but closed for modification Don t call us, we ll call you Dep on abstractions, do not dep on concrete classes Classes should only have one reason to change Strive for loosely-coupled design

9 Liskov substitution Encapsulate what varies Program to an interface, not to an implementation Favor composition over inheritance Classes should be open for extension but closed for modification Don t call us, we ll call you Dep on abstractions, do not dep on concrete classes Classes should only have one reason to change Strive for loosely-coupled design

10 Liskov substitution Encapsulate what varies Program to an interface, not to an implementation Favor composition over inheritance Classes should be open for extension but closed for modification Don t call us, we ll call you Dep on abstractions, do not dep on concrete classes Classes should only have one reason to change Strive for loosely-coupled design

11 Interface segregation Encapsulate what varies Program to an interface, not to an implementation Favor composition over inheritance Classes should be open for extension but closed for modification Don t call us, we ll call you Dep on abstractions, do not dep on concrete classes Classes should only have one reason to change Strive for loosely-coupled design

12 Interface segregation Encapsulate what varies Program to an interface, not to an implementation Favor composition over inheritance Classes should be open for extension but closed for modification Don t call us, we ll call you Dep on abstractions, do not dep on concrete classes Classes should only have one reason to change Strive for loosely-coupled design

13 Depency inversion Encapsulate what varies Program to an interface, not to an implementation Favor composition over inheritance Classes should be open for extension but closed for modification Don t call us, we ll call you Dep on abstractions, do not dep on concrete classes Classes should only have one reason to change Strive for loosely-coupled design

14 Depency inversion Encapsulate what varies Program to an interface, not to an implementation Favor composition over inheritance Classes should be open for extension but closed for modification Don t call us, we ll call you Dep on abstractions, do not dep on concrete classes Classes should only have one reason to change Strive for loosely-coupled design

15 Depency inversion Encapsulate what varies Program to an interface, not to an implementation Favor composition over inheritance Classes should be open for extension but closed for modification Don t call us, we ll call you Dep on abstractions, do not dep on concrete classes Classes should only have one reason to change Strive for loosely-coupled design

16 Depency inversion Encapsulate what varies Program to an interface, not to an implementation Favor composition over inheritance Classes should be open for extension but closed for modification Don t call us, we ll call you Dep on abstractions, do not dep on concrete classes Classes should only have one reason to change Strive for loosely-coupled design

17 Encapsulate what varies Strive for loosely-coupled design

18 Too general? Encapsulate what varies Strive for loosely-coupled design

19 Too general? Encapsulate what varies Strive for loosely-coupled design A consequence of applying SOLID?

20 Too general? Too trivial? Encapsulate what varies Strive for loosely-coupled design A consequence of applying SOLID?

21 Language Design vs Design Patterns

22 Language features Open classes: The ability to redefine classes Metaprogramming: The ability to inspect and manipulate programs and their processes from within the language Multiple dispatch: The ability to select a function based on the runtime types of all arguments First-order functions: The ability to use functions as objects

23 Open classes

24 C# Open classes public static class ObjectExtensions {!!! 1.ToXML ();!!! new Person ().ToXML (); public static string ToXML(this object objecttoserialize) { MemoryStream mem=new MemoryStream(); XmlSerializer ser=new XmlSerializer(objectToSerialize.GetType()); ser.serialize(mem,objecttoserialize); ASCIIEncoding ascii=new ASCIIEncoding(); return ascii.getstring(mem.toarray()); }

25 C# Open classes public static class ObjectExtensions {!!! 1.ToXML ();!!! new Person ().ToXML (); Ruby public static string ToXML(this object objecttoserialize) { MemoryStream mem=new MemoryStream(); XmlSerializer ser=new XmlSerializer(objectToSerialize.GetType()); ser.serialize(mem,objecttoserialize); ASCIIEncoding ascii=new ASCIIEncoding(); return ascii.getstring(mem.toarray()); } class Object def to_xml vars = instance_variables.map do var name=var.to_s.sub('@','') "<#{name}>#{instance_variable_get(var)}</#{name}>".join(" ") "<root>#{vars}</root>" irb(main):081:0> p.to_xml "<root><name>ola</name> <age>34</age></root>" class Person attr_accessor :name, :age p = Person.new p.name = "Ola" p.age = 34

26 Metaprogramming C# public class FieldMappingConfigurator<T> where T: class, new() { private Configurator Configurator { get; set; } private string FieldName { get; set; } internal FieldMappingConfigurator(string fieldname, Configurator configurator) { Configurator = configurator; FieldName = fieldname; } } public void To<T1>(Expression<Func<T,T1>> propertyselector) { var selectorexpression = (MemberExpression) propertyselector.body; var prop = (PropertyInfo) selectorexpression.member; Configurator.CustomFieldsToPropertiesMap[FieldName]=prop; } GenericDAO<DomainObject>.Configure("some_StoredProcedure").Map("AFieldInTheResultSetReturned").To(s => s.id);

27 Metaprogramming C# public class FieldMappingConfigurator<T> where T: class, new() { private Configurator Configurator { get; set; } private string FieldName { get; set; } internal FieldMappingConfigurator(string fieldname, Configurator configurator) { Configurator = configurator; FieldName = fieldname; } } public void To<T1>(Expression<Func<T,T1>> propertyselector) { var selectorexpression = (MemberExpression) propertyselector.body; var prop = (PropertyInfo) selectorexpression.member; Configurator.CustomFieldsToPropertiesMap[FieldName]=prop; } GenericDAO<DomainObject>.Configure("some_StoredProcedure").Map("AFieldInTheResultSetReturned").To(s => s.id);

28 Metaprogramming C# public class FieldMappingConfigurator<T> where T: class, new() { private Configurator Configurator { get; set; } private string FieldName { get; set; } internal FieldMappingConfigurator(string fieldname, Configurator configurator) { Configurator = configurator; FieldName = fieldname; } } public void To<T1>(Expression<Func<T,T1>> propertyselector) { var selectorexpression = (MemberExpression) propertyselector.body; var prop = (PropertyInfo) selectorexpression.member; Configurator.CustomFieldsToPropertiesMap[FieldName]=prop; } GenericDAO<DomainObject>.Configure("some_StoredProcedure").Map("AFieldInTheResultSetReturned").To(s => s.id);

29 Metaprogramming GenericDAO<DomainObject>.Configure("some_StoredProcedure").Map("AFieldInTheResultSetReturned").To(s => s.id); C# public class FieldMappingConfigurator<T> where T: class, new() { private Configurator Configurator { get; set; } private string FieldName { get; set; } internal FieldMappingConfigurator(string fieldname, Configurator configurator) { Configurator = configurator; FieldName = fieldname; } } public void To<T1>(Expression<Func<T,T1>> propertyselector) { var selectorexpression = (MemberExpression) propertyselector.body; var prop = (PropertyInfo) selectorexpression.member; Configurator.CustomFieldsToPropertiesMap[FieldName]=prop; } Program analysis

30 Metaprogramming class SetupProjectBuilder class << self def = [] Ruby def inherited(sub_class) setup_classes << sub_class def setup_project?(project_file)!setup_class(project_file).nil? def setup_class(project_file) setup_classes.find { c c.project_file_pattern =~ project_file } class VDProjBuilder < SetupProjectBuilder def self.project_file_pattern /\.vdproj$/ [... ]

31 Metaprogramming class SetupProjectBuilder class << self def = [] Ruby def inherited(sub_class) setup_classes << sub_class def setup_project?(project_file)!setup_class(project_file).nil? Process analysis def setup_class(project_file) setup_classes.find { c c.project_file_pattern =~ project_file } class VDProjBuilder < SetupProjectBuilder def self.project_file_pattern /\.vdproj$/ [... ]

32 Metaprogramming class SetupProjectBuilder class << self Method-related hooks Ruby def = [] def inherited(sub_class) setup_classes << sub_class def setup_project?(project_file)!setup_class(project_file).nil? Process analysis def setup_class(project_file) setup_classes.find { c c.project_file_pattern =~ project_file } method_missing method_added singleton_method_added method_removed singleton_method_removed method_undefined singleton_method_undefined Class & Module Hooks inherited app_features included ext_object exted initialize_copy const_missing class VDProjBuilder < SetupProjectBuilder def self.project_file_pattern /\.vdproj$/ [... ]

33 Metaprogramming class SetupProjectBuilder class << self Method-related hooks Ruby def = [] def inherited(sub_class) setup_classes << sub_class def setup_project?(project_file)!setup_class(project_file).nil? Process analysis def setup_class(project_file) setup_classes.find { c c.project_file_pattern =~ project_file } method_missing method_added singleton_method_added method_removed singleton_method_removed method_undefined singleton_method_undefined Class & Module Hooks inherited app_features included ext_object exted initialize_copy const_missing class VDProjBuilder < SetupProjectBuilder def self.project_file_pattern /\.vdproj$/ [... ]

34 Metaprogramming class SetupProjectBuilder class << self Method-related hooks Ruby def = [] def inherited(sub_class) setup_classes << sub_class def setup_project?(project_file)!setup_class(project_file).nil? Process analysis def setup_class(project_file) setup_classes.find { c c.project_file_pattern =~ project_file } method_missing method_added singleton_method_added method_removed singleton_method_removed method_undefined singleton_method_undefined Class & Module Hooks inherited app_features included ext_object exted initialize_copy const_missing class VDProjBuilder < SetupProjectBuilder Factory Method def self.project_file_pattern /\.vdproj$/ [... ]

35 Metaprogramming in Ruby class YamlConf def = load(self.class.simple_name+".yml") # Look up keys in the configuration hash def method_missing(method,*args) method_name=method.to_s conf[method_name]

36 Metaprogramming in Ruby class YamlConf def = load(self.class.simple_name+".yml") # Look up keys in the configuration hash def method_missing(method,*args) method_name=method.to_s conf[method_name] class Mail < YamlConf;

37 Metaprogramming in Ruby class YamlConf def = load(self.class.simple_name+".yml") # Look up keys in the configuration hash def method_missing(method,*args) method_name=method.to_s conf[method_name] class Mail < YamlConf; config/mail.yml from: "john.appleseed@apple.com" to: - "ola.leifler@liu.se" - "tommy.farnqvist@liu.se" host: "smtp.somehost.com"

38 Metaprogramming in Ruby class YamlConf def = load(self.class.simple_name+".yml") # Look up keys in the configuration hash def method_missing(method,*args) method_name=method.to_s conf[method_name] class Mail < YamlConf; mail = Mail.new do from Conf::Mail.from to Conf::Mail.to subject s body b config/mail.yml from: "john.appleseed@apple.com" to: - "ola.leifler@liu.se" - "tommy.farnqvist@liu.se" host: "smtp.somehost.com"

39 Metaprogramming in Ruby class YamlConf def = load(self.class.simple_name+".yml") # Look up keys in the configuration hash def method_missing(method,*args) method_name=method.to_s conf[method_name] class Mail < YamlConf; mail = Mail.new do from Conf::Mail.from to Conf::Mail.to subject s body b config/mail.yml from: "john.appleseed@apple.com" to: - "ola.leifler@liu.se" - "tommy.farnqvist@liu.se" host: "smtp.somehost.com"

40 Metaprogramming in Ruby class YamlConf def = load(self.class.simple_name+".yml") # Look up keys in the configuration hash def method_missing(method,*args) method_name=method.to_s conf[method_name] class Mail < YamlConf; mail = Mail.new do from Conf::Mail.from to Conf::Mail.to subject s body b config/mail.yml from: "john.appleseed@apple.com" to: - "ola.leifler@liu.se" - "tommy.farnqvist@liu.se" host: "smtp.somehost.com"

41 Metaprogramming in Ruby class YamlConf def = load(self.class.simple_name+".yml") # Look up keys in the configuration hash def method_missing(method,*args) method_name=method.to_s conf[method_name] class Mail < YamlConf; mail = Mail.new do from Conf::Mail.from to Conf::Mail.to subject s body b config/mail.yml from: "john.appleseed@apple.com" to: - "ola.leifler@liu.se" - "tommy.farnqvist@liu.se" host: "smtp.somehost.com" Proxy

42 Metaprogramming in Java public State() { ClassWithState obj = ClassWithState.this; manipulatefields(obj, new FieldManipulator() public void manipulatefield(object obj, Field field) throws IllegalAccessException { } getstate().put(field.getname(), field.get(obj)); } }); private void manipulatefields(object obj, FieldManipulator fieldmanipulator) { Class<?> cl = obj.getclass(); for (Field field : cl.getdeclaredfields()) { field.setaccessible(true); try { fieldmanipulator.manipulatefield(obj, field); } catch (IllegalArgumentException e) { e.printstacktrace(); } catch (IllegalAccessException e) { e.printstacktrace(); } } }

43 Metaprogramming in Java public State() { ClassWithState obj = ClassWithState.this; manipulatefields(obj, new FieldManipulator() public void manipulatefield(object obj, Field field) throws IllegalAccessException { } getstate().put(field.getname(), field.get(obj)); } }); Memento private void manipulatefields(object obj, FieldManipulator fieldmanipulator) { Class<?> cl = obj.getclass(); for (Field field : cl.getdeclaredfields()) { field.setaccessible(true); try { fieldmanipulator.manipulatefield(obj, field); } catch (IllegalArgumentException e) { e.printstacktrace(); } catch (IllegalAccessException e) { e.printstacktrace(); } } }

44 Metaprogramming in public Object invoke(object arg0, Method m, Object[] arg2) throws Throwable { Object result = m.invoke(instance, arg2); if (m.getname().equals("getemployments") && result == null) { } System.out.println(MessageFormat.format( "Trying to access uninstantiated field {0}", m.getname().substring(3))); [ some magic happens ] Method setter = m.getdeclaringclass().getmethod( "setemployments", Collection.class); System.out.println(MessageFormat.format( "Instantiated field {0}", m.getname().substring(3))); setter.invoke(instance, employments); } return m.invoke(instance, arg2);

45 Metaprogramming in public Object invoke(object arg0, Method m, Object[] arg2) throws Throwable { Object result = m.invoke(instance, arg2); if (m.getname().equals("getemployments") && result == null) { } System.out.println(MessageFormat.format( "Trying to access uninstantiated field {0}", m.getname().substring(3))); [ some magic happens ] Method setter = m.getdeclaringclass().getmethod( "setemployments", Collection.class); System.out.println(MessageFormat.format( "Instantiated field {0}", m.getname().substring(3))); setter.invoke(instance, employments); } return m.invoke(instance, arg2); Proxy

46 Multiple dispatch (defclass duck () ((name :initarg :name :accessor name))) (defclass mallard-duck (duck) ()) (defclass red-duck (duck) ()) (defclass rubber-duck (duck) ()) ;; In another file, we can add flying behavior ;; What design pattern is this an implementation of? (defclass fly-behavior () ()) (defclass fly-with-wings (fly-behavior) ()) (defclass no-fly (fly-behavior) ()) (defgeneric fly (duck fly-behavior) (:documentation "A method to allow ducks to fly") (:method ((d mallard-duck) (b fly-with-wings)) (format t "The mallard duck ~A is flying with wings!" (name d))) (:method ((d rubber-duck) (b fly-with-wings)) (format t "Rubber duck ~A is flying with wings!" (name d))) (:method ((d rubber-duck) (b no-fly)) (format t "Rubber duck ~A is not flying at all" (name d))) )

47 Multiple dispatch (defclass duck () ((name :initarg :name :accessor name))) (defclass mallard-duck (duck) ()) (defclass red-duck (duck) ()) (defclass rubber-duck (duck) ()) ;; In another file, we can add flying behavior ;; What design pattern is this an implementation of? (defclass fly-behavior () ()) (defclass fly-with-wings (fly-behavior) ()) (defclass no-fly (fly-behavior) ()) (defgeneric fly (duck fly-behavior) (:documentation "A method to allow ducks to fly") (:method ((d mallard-duck) (b fly-with-wings)) (format t "The mallard duck ~A is flying with wings!" (name d))) (:method ((d rubber-duck) (b fly-with-wings)) (format t "Rubber duck ~A is flying with wings!" (name d))) (:method ((d rubber-duck) (b no-fly)) (format t "Rubber duck ~A is not flying at all" (name d))) ) Method description

48 Multiple dispatch (defclass duck () ((name :initarg :name :accessor name))) (defclass mallard-duck (duck) ()) (defclass red-duck (duck) ()) (defclass rubber-duck (duck) ()) ;; In another file, we can add flying behavior ;; What design pattern is this an implementation of? (defclass fly-behavior () ()) (defclass fly-with-wings (fly-behavior) ()) (defclass no-fly (fly-behavior) ()) (defgeneric fly (duck fly-behavior) (:documentation "A method to allow ducks to fly") (:method ((d mallard-duck) (b fly-with-wings)) (format t "The mallard duck ~A is flying with wings!" (name d))) (:method ((d rubber-duck) (b fly-with-wings)) (format t "Rubber duck ~A is flying with wings!" (name d))) (:method ((d rubber-duck) (b no-fly)) (format t "Rubber duck ~A is not flying at all" (name d))) ) Method description ;; CL-USER> (fly (make-instance 'rubber-duck :name "Ducky") (make-instance 'fly-with-wings)) ;; Rubber duck Ducky is flying with wings! ;; NIL ;; CL-USER> (fly (make-instance 'rubber-duck :name "Ducky") (make-instance 'no-fly)) ;; Rubber duck Ducky is not flying at all

49 Multiple dispatch (defclass duck () ((name :initarg :name :accessor name))) (defclass mallard-duck (duck) ()) (defclass red-duck (duck) ()) (defclass rubber-duck (duck) ()) ;; In another file, we can add flying behavior ;; What design pattern is this an implementation of? (defclass fly-behavior () ()) (defclass fly-with-wings (fly-behavior) ()) (defclass no-fly (fly-behavior) ()) (defgeneric fly (duck fly-behavior) (:documentation "A method to allow ducks to fly") (:method ((d mallard-duck) (b fly-with-wings)) (format t "The mallard duck ~A is flying with wings!" (name d))) (:method ((d rubber-duck) (b fly-with-wings)) (format t "Rubber duck ~A is flying with wings!" (name d))) (:method ((d rubber-duck) (b no-fly)) (format t "Rubber duck ~A is not flying at all" (name d))) ) Method description Method dispatch ;; CL-USER> (fly (make-instance 'rubber-duck :name "Ducky") (make-instance 'fly-with-wings)) ;; Rubber duck Ducky is flying with wings! ;; NIL ;; CL-USER> (fly (make-instance 'rubber-duck :name "Ducky") (make-instance 'no-fly)) ;; Rubber duck Ducky is not flying at all

50 Multiple dispatch (defclass duck () ((name :initarg :name :accessor name))) (defclass mallard-duck (duck) ()) (defclass red-duck (duck) ()) (defclass rubber-duck (duck) ()) ;; In another file, we can add flying behavior ;; What design pattern is this an implementation of? (defclass fly-behavior () ()) (defclass fly-with-wings (fly-behavior) ()) (defclass no-fly (fly-behavior) ()) (defgeneric fly (duck fly-behavior) (:documentation "A method to allow ducks to fly") (:method ((d mallard-duck) (b fly-with-wings)) (format t "The mallard duck ~A is flying with wings!" (name d))) (:method ((d rubber-duck) (b fly-with-wings)) (format t "Rubber duck ~A is flying with wings!" (name d))) (:method ((d rubber-duck) (b no-fly)) (format t "Rubber duck ~A is not flying at all" (name d))) ) Method description Method dispatch ;; CL-USER> (fly (make-instance 'rubber-duck :name "Ducky") (make-instance 'fly-with-wings)) ;; Rubber duck Ducky is flying with wings! ;; NIL ;; CL-USER> (fly (make-instance 'rubber-duck :name "Ducky") (make-instance 'no-fly)) ;; Rubber duck Ducky is not flying at all Strategy

51 (defclass expression () ()) (defclass compound-expression (expression) ((left :initarg :left :accessor left) (operator :initarg :operator :accessor operator) (right :initarg :right :accessor right))) (defclass atomic (expression) ((value :initarg :value :accessor value))) compoundexpression expression atomic ;;;;;;;; Indepently of the classes above, we define a way to ;;;;;;;; perform different operations on the objects of each class ;; What pattern would this correspond in the GoF book? (defgeneric get-value (Expression) (:documentation "Calculates the value of the expression ") (:method ((self compound-expression)) (funcall (operator self)! (get-value (left self))! (get-value (right self)))) (:method ((self atomic)) (value self))) (defvar expression (make-instance 'compound-expression!!! :left (make-instance 'atomic :value 3)!!! :operator #'*!!! :right (make-instance 'atomic :value 4))) (defvar expression2 (make-instance 'compound-expression!!! :left expression!!! :operator #'+!!! :right (make-instance 'atomic :value 5)!!! )) expression2 + expression * 5 (get-value expression2) 3 4

52 (defclass expression () ()) (defclass compound-expression (expression) ((left :initarg :left :accessor left) (operator :initarg :operator :accessor operator) (right :initarg :right :accessor right))) (defclass atomic (expression) ((value :initarg :value :accessor value))) compoundexpression expression atomic ;;;;;;;; Indepently of the classes above, we define a way to ;;;;;;;; perform different operations on the objects of each class ;; What pattern would this correspond in the GoF book? (defgeneric get-value (Expression) (:documentation "Calculates the value of the expression ") (:method ((self compound-expression)) (funcall (operator self)! (get-value (left self))! (get-value (right self)))) (:method ((self atomic)) (value self))) (defvar expression (make-instance 'compound-expression!!! :left (make-instance 'atomic :value 3)!!! :operator #'*!!! :right (make-instance 'atomic :value 4))) (defvar expression2 (make-instance 'compound-expression!!! :left expression!!! :operator #'+!!! :right (make-instance 'atomic :value 5)!!! )) expression2 + expression * 5 (get-value expression2) 3 4 Visitor

53 First-order functions C# new List<int> () { 1, 2, 3 }.Select (x => x +2); => { 3, 4, 5 } Ruby [1,2,3].collect { x x+2 } => [3,4,5] Lisp (mapcar #'(lambda (x) (+ x 2)) '(1 2 3)) => (3 4 5)

54 First-order functions C# new List<int> () { 1, 2, 3 }.Select (x => x +2); => { 3, 4, 5 } Ruby [1,2,3].collect { x x+2 } => [3,4,5] Lisp (mapcar #'(lambda (x) (+ x 2)) '(1 2 3)) => (3 4 5)

55 First-order functions C# new List<int> () { 1, 2, 3 }.Select (x => x +2); => { 3, 4, 5 } Ruby [1,2,3].collect { x x+2 } => [3,4,5] Lisp (mapcar #'(lambda (x) (+ x 2)) '(1 2 3)) => (3 4 5)

56 First-order functions C# new List<int> () { 1, 2, 3 }.Select (x => x +2); => { 3, 4, 5 } Ruby [1,2,3].collect { x x+2 } => [3,4,5] Lisp (mapcar #'(lambda (x) (+ x 2)) '(1 2 3)) => (3 4 5)

57 First-order functions C# new List<int> () { 1, 2, 3 }.Select (x => x +2); => { 3, 4, 5 } Ruby [1,2,3].collect { x x+2 } => [3,4,5] Lisp (mapcar #'(lambda (x) (+ x 2)) '(1 2 3)) => (3 4 5) Strategy

58 Open classes vs Design Patterns Creational Factory method Abstract Factory Singleton Prototype Strategy Builder Structural Decorator Facade Composite Proxy Flyweight Bridge Adapter Behavioral State Command Template method Iterator Visitor Interpreter Mediator Chain of responsibility Observer Memento Highlighted patterns simplified

59 Open classes vs Design Patterns Creational Factory method Abstract Factory Singleton Prototype Strategy Builder Structural Decorator Facade Composite Proxy Flyweight Bridge Adapter Behavioral State Command Template method Iterator Visitor Interpreter Mediator Chain of responsibility Observer Memento Highlighted patterns simplified

60 Metaprogramming vs Design Patterns Creational Factory method Abstract Factory Singleton Prototype Strategy Builder Structural Decorator Facade Composite Proxy Flyweight Bridge Adapter Behavioral State Command Template method Iterator Visitor Interpreter Mediator Chain of responsibility Observer Memento Highlighted patterns simplified

61 Metaprogramming vs Design Patterns Creational Factory method Abstract Factory Singleton Prototype Strategy Builder Structural Decorator Facade Composite Proxy Flyweight Bridge Adapter Behavioral State Command Template method Iterator Visitor Interpreter Mediator Chain of responsibility Observer Memento Highlighted patterns simplified

62 Multiple dispatch vs Design Patterns Creational Factory method Abstract Factory Singleton Prototype Strategy Builder Structural Decorator Facade Composite Proxy Flyweight Bridge Adapter Behavioral State Command Template method Iterator Visitor Interpreter Mediator Chain of responsibility Observer Memento Highlighted patterns simplified

63 Multiple dispatch vs Design Patterns Creational Factory method Abstract Factory Singleton Prototype Strategy Builder Structural Decorator Facade Composite Proxy Flyweight Bridge Adapter Behavioral State Command Template method Iterator Visitor Interpreter Mediator Chain of responsibility Observer Memento Highlighted patterns simplified

64 First-order functions vs Design Patterns Creational Factory method Abstract Factory Singleton Prototype Strategy Builder Structural Decorator Facade Composite Proxy Flyweight Bridge Adapter Behavioral State Command Template method Iterator Visitor Interpreter Mediator Chain of responsibility Observer Memento Highlighted patterns simplified

65 First-order functions vs Design Patterns Creational Factory method Abstract Factory Singleton Prototype Strategy Builder Structural Decorator Facade Composite Proxy Flyweight Bridge Adapter Behavioral State Command Template method Iterator Visitor Interpreter Mediator Chain of responsibility Observer Memento Highlighted patterns simplified

66 Summary

67 What is Good Design?

68 Encapsulate what varies Program to an interface, not to an implementation Favor composition over inheritance Classes should be open for extension but closed for modification Don t call us, we ll call you Dep on abstractions, do not dep on concrete classes Classes should only have one reason to change Strive for loosely-coupled design

69 Or...

70 Or... Testable programs

71 Or... Testable programs Changeable programs

72 Or... Testable programs Changeable programs

73 Or... Testable programs Changeable programs Test Change

74 What is a Design Pattern?

75 What is a Design Pattern? Why are there Design Patterns?

76 What is a Design Pattern? Why are there Design Patterns? How are Design Patterns used/recognized?

77 Why

78 Why 1. There are OO Programming Languages

79 Why 1. There are OO Programming Languages 2. There are Common Problems

80 Why 1. There are OO Programming Languages 2. There are Common Problems 3. There are Design Principles

81 Why 1. There are OO Programming Languages 2. There are Common Problems 3. There are Design Principles = Design Pattern

82 How

83 How 1. There are Structure Diagrams

84 How 1. There are Structure Diagrams 2. There are A Bunch of Other Attributes

85 How 1. There are Structure Diagrams 2. There are A Bunch of Other Attributes 1+2 = Design Pattern

86 Other Patterns

87 Other Patterns Simpleton The Simpleton Pattern is an extremely complex pattern used for the most trivial of tasks. The Simpleton is an accurate indicator of the skill level of its creator.

88 Other Patterns Simpleton The Simpleton Pattern is an extremely complex pattern used for the most trivial of tasks. The Simpleton is an accurate indicator of the skill level of its creator. Commando The Commando Pattern is used to get in and out quick, and get the job done. This pattern can break any encapsulation to accomplish its mission. It takes no prisoners.

89 Other Patterns Simpleton The Simpleton Pattern is an extremely complex pattern used for the most trivial of tasks. The Simpleton is an accurate indicator of the skill level of its creator. Commando The Commando Pattern is used to get in and out quick, and get the job done. This pattern can break any encapsulation to accomplish its mission. It takes no prisoners.

90 The Exam

91 Oct 25th 8-12 Bring written notes & the books. Justify all your reasoning. Good luck!

92 Thank you!

TDDB84. Lecture 2. fredag 6 september 13

TDDB84. Lecture 2. fredag 6 september 13 TDDB84 Lecture 2 Yes, you can bring the books to the exam Creational Factory method Structural Decorator Behavioral LE2 Creational Abstract Factory Singleton Builder Structural Composite Proxy Bridge Adapter

More information

The Strategy Pattern Design Principle: Design Principle: Design Principle:

The Strategy Pattern Design Principle: Design Principle: Design Principle: Strategy Pattern The Strategy Pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it. Design

More information

Exam in TDDB84: Design Patterns,

Exam in TDDB84: Design Patterns, Exam in TDDB84: Design Patterns, 2014-10-24 14-18 Information Observe the following, or risk subtraction of points: 1) Write only the answer to one task on one sheet. Use only the front side of the sheets

More information

TDDB84: Lecture 5. Singleton, Builder, Proxy, Mediator. fredag 27 september 13

TDDB84: Lecture 5. Singleton, Builder, Proxy, Mediator. fredag 27 september 13 TDDB84: Lecture 5 Singleton, Builder, Proxy, Mediator Creational Abstract Factory Singleton Builder Structural Composite Proxy Bridge Adapter Template method Behavioral Iterator Mediator Chain of responsibility

More information

TDDB84: Lecture 6. Adapter, Bridge, Observer, Chain of Responsibility, Memento, Command. fredag 4 oktober 13

TDDB84: Lecture 6. Adapter, Bridge, Observer, Chain of Responsibility, Memento, Command. fredag 4 oktober 13 TDDB84: Lecture 6 Adapter, Bridge, Observer, Chain of Responsibility, Memento, Command Creational Abstract Factory Singleton Builder Structural Composite Proxy Bridge Adapter Template method Behavioral

More information

SDC Design patterns GoF

SDC Design patterns GoF SDC Design patterns GoF Design Patterns The design pattern concept can be viewed as an abstraction of imitating useful parts of other software products. The design pattern is a description of communicating

More information

Object Oriented Methods with UML. Introduction to Design Patterns- Lecture 8

Object Oriented Methods with UML. Introduction to Design Patterns- Lecture 8 Object Oriented Methods with UML Introduction to Design Patterns- Lecture 8 Topics(03/05/16) Design Patterns Design Pattern In software engineering, a design pattern is a general repeatable solution to

More information

Design Pattern. CMPSC 487 Lecture 10 Topics: Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, et al.)

Design Pattern. CMPSC 487 Lecture 10 Topics: Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, et al.) Design Pattern CMPSC 487 Lecture 10 Topics: Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, et al.) A. Design Pattern Design patterns represent the best practices used by experienced

More information

Design Patterns. Manuel Mastrofini. Systems Engineering and Web Services. University of Rome Tor Vergata June 2011

Design Patterns. Manuel Mastrofini. Systems Engineering and Web Services. University of Rome Tor Vergata June 2011 Design Patterns Lecture 1 Manuel Mastrofini Systems Engineering and Web Services University of Rome Tor Vergata June 2011 Definition A pattern is a reusable solution to a commonly occurring problem within

More information

TDDB84: Lecture 7. State, Visitor, Interpreter, DSL. fredag 4 oktober 13

TDDB84: Lecture 7. State, Visitor, Interpreter, DSL. fredag 4 oktober 13 TDDB84: Lecture 7 State, Visitor, Interpreter, DSL Creational Prototype SOLID Structural Facade Flyweight Behavioral State Visitor Interpreter Summary The exam LE7 LE8 LE9 Several different patterns GUI

More information

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich CSCD01 Engineering Large Software Systems Design Patterns Joe Bettridge Winter 2018 With thanks to Anya Tafliovich Design Patterns Design patterns take the problems consistently found in software, and

More information

Object-oriented Software Design Patterns

Object-oriented Software Design Patterns Object-oriented Software Design Patterns Concepts and Examples Marcelo Vinícius Cysneiros Aragão marcelovca90@inatel.br Topics What are design patterns? Benefits of using design patterns Categories and

More information

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar Design Patterns MSc in Communications Software Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie

More information

Design patterns. Jef De Smedt Beta VZW

Design patterns. Jef De Smedt Beta VZW Design patterns Jef De Smedt Beta VZW Who Beta VZW www.betavzw.org Association founded in 1993 Computer training for the unemployed Computer training for employees (Cevora/Cefora) 9:00-12:30 13:00-16:00

More information

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 6: Design Patterns

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 6: Design Patterns EPL 603 TOPICS IN SOFTWARE ENGINEERING Lab 6: Design Patterns Links to Design Pattern Material 1 http://www.oodesign.com/ http://www.vincehuston.org/dp/patterns_quiz.html Types of Design Patterns 2 Creational

More information

Using Design Patterns in Java Application Development

Using Design Patterns in Java Application Development Using Design Patterns in Java Application Development ExxonMobil Research & Engineering Co. Clinton, New Jersey Michael P. Redlich (908) 730-3416 michael.p.redlich@exxonmobil.com About Myself Degree B.S.

More information

Introduction to Software Engineering: Object Design I Reuse & Patterns

Introduction to Software Engineering: Object Design I Reuse & Patterns Introduction to Software Engineering: Object Design I Reuse & Patterns John T. Bell Department of Computer Science University of Illinois, Chicago Based on materials from Bruegge & DuToit 3e, Chapter 8,

More information

Trusted Components. Reuse, Contracts and Patterns. Prof. Dr. Bertrand Meyer Dr. Karine Arnout

Trusted Components. Reuse, Contracts and Patterns. Prof. Dr. Bertrand Meyer Dr. Karine Arnout 1 Last update: 2 November 2004 Trusted Components Reuse, Contracts and Patterns Prof. Dr. Bertrand Meyer Dr. Karine Arnout 2 Lecture 5: Design patterns Agenda for today 3 Overview Benefits of patterns

More information

UNIT I Introduction to Design Patterns

UNIT I Introduction to Design Patterns SIDDHARTH GROUP OF INSTITUTIONS :: PUTTUR Siddharth Nagar, Narayanavanam Road 517583 QUESTION BANK (DESCRIPTIVE) Subject with Code : Design Patterns (16MC842) Year & Sem: III-MCA I-Sem Course : MCA Regulation:

More information

DESIGN PATTERN - INTERVIEW QUESTIONS

DESIGN PATTERN - INTERVIEW QUESTIONS DESIGN PATTERN - INTERVIEW QUESTIONS http://www.tutorialspoint.com/design_pattern/design_pattern_interview_questions.htm Copyright tutorialspoint.com Dear readers, these Design Pattern Interview Questions

More information

Design Pattern and Software Architecture: IV. Design Pattern

Design Pattern and Software Architecture: IV. Design Pattern Design Pattern and Software Architecture: IV. Design Pattern AG Softwaretechnik Raum E 3.165 Tele.. 60-3321 hg@upb.de IV. Design Pattern IV.1 Introduction IV.2 Example: WYSIWYG Editor Lexi IV.3 Creational

More information

UNIT I Introduction to Design Patterns

UNIT I Introduction to Design Patterns SIDDHARTH GROUP OF INSTITUTIONS :: PUTTUR Siddharth Nagar, Narayanavanam Road 517583 QUESTION BANK (DESCRIPTIVE) Subject with Code : Design Patterns(9F00505c) Year & Sem: III-MCA I-Sem Course : MCA Regulation:

More information

Software Design COSC 4353/6353 D R. R A J S I N G H

Software Design COSC 4353/6353 D R. R A J S I N G H Software Design COSC 4353/6353 D R. R A J S I N G H Design Patterns What are design patterns? Why design patterns? Example DP Types Toolkit, Framework, and Design Pattern A toolkit is a library of reusable

More information

Applying Design Patterns to SCA Implementations

Applying Design Patterns to SCA Implementations Applying Design Patterns to SCA Implementations Adem ZUMBUL (TUBITAK-UEKAE, ademz@uekae.tubitak.gov.tr) Tuna TUGCU (Bogazici University, tugcu@boun.edu.tr) SDR Forum Technical Conference, 26-30 October

More information

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich CSCD01 Engineering Large Software Systems Design Patterns Joe Bettridge Winter 2018 With thanks to Anya Tafliovich Design Patterns Design patterns take the problems consistently found in software, and

More information

Software Development Project. Kazi Masudul Alam

Software Development Project. Kazi Masudul Alam Software Development Project Kazi Masudul Alam Course Objective Study Programming Best Practices Apply the knowledge to build a Small Software in Groups 7/10/2017 2 Programming Best Practices Code Formatting

More information

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1 Ingegneria del Software Corso di Laurea in Informatica per il Management Design Patterns part 1 Davide Rossi Dipartimento di Informatica Università di Bologna Pattern Each pattern describes a problem which

More information

C++ for System Developers with Design Pattern

C++ for System Developers with Design Pattern C++ for System Developers with Design Pattern Introduction: This course introduces the C++ language for use on real time and embedded applications. The first part of the course focuses on the language

More information

CSCI 253. Overview. The Elements of a Design Pattern. George Blankenship 1. Object Oriented Design: Template Method Pattern. George Blankenship

CSCI 253. Overview. The Elements of a Design Pattern. George Blankenship 1. Object Oriented Design: Template Method Pattern. George Blankenship CSCI 253 Object Oriented Design: George Blankenship George Blankenship 1 Creational Patterns Singleton Abstract factory Factory Method Prototype Builder Overview Structural Patterns Composite Façade Proxy

More information

Object-Oriented Oriented Programming

Object-Oriented Oriented Programming Object-Oriented Oriented Programming Composite Pattern CSIE Department, NTUT Woei-Kae Chen Catalog of Design patterns Creational patterns Abstract Factory, Builder, Factory Method, Prototype, Singleton

More information

Design Patterns: Structural and Behavioural

Design Patterns: Structural and Behavioural Design Patterns: Structural and Behavioural 3 April 2009 CMPT166 Dr. Sean Ho Trinity Western University See also: Vince Huston Review last time: creational Design patterns: Reusable templates for designing

More information

Applying the Observer Design Pattern

Applying the Observer Design Pattern Applying the Observer Design Pattern Trenton Computer Festival Professional Seminars Michael P. Redlich (908) 730-3416 michael.p.redlich@exxonmobil.com About Myself Degree B.S. in Computer Science Rutgers

More information

Design Patterns Reid Holmes

Design Patterns Reid Holmes Material and some slide content from: - Head First Design Patterns Book - GoF Design Patterns Book Design Patterns Reid Holmes GoF design patterns $ %!!!! $ "! # & Pattern vocabulary Shared vocabulary

More information

OODP Session 4. Web Page: Visiting Hours: Tuesday 17:00 to 19:00

OODP Session 4.   Web Page:   Visiting Hours: Tuesday 17:00 to 19:00 OODP Session 4 Session times PT group 1 Monday 18:00 21:00 room: Malet 403 PT group 2 Thursday 18:00 21:00 room: Malet 407 FT Tuesday 13:30 17:00 room: Malet 404 Email: oded@dcs.bbk.ac.uk Web Page: http://www.dcs.bbk.ac.uk/~oded

More information

Lecture 4: Observer Pattern, Event Library and Componentization

Lecture 4: Observer Pattern, Event Library and Componentization Software Architecture Bertrand Meyer & Till Bay ETH Zurich, February-May 2008 Lecture 4: Observer Pattern, Event Library and Componentization Program overview Date Topic Who? last week Introduction; A

More information

CSCI 253. Overview. The Elements of a Design Pattern. George Blankenship 1. Object Oriented Design: Iterator Pattern George Blankenship

CSCI 253. Overview. The Elements of a Design Pattern. George Blankenship 1. Object Oriented Design: Iterator Pattern George Blankenship CSCI 253 Object Oriented Design: Iterator Pattern George Blankenship George Blankenship 1 Creational Patterns Singleton Abstract factory Factory Method Prototype Builder Overview Structural Patterns Composite

More information

Writing your own Java I/O Decorator p. 102 Tools for your Design Toolbox p. 105 Exercise Solutions p. 106 The Factory Pattern Baking with OO

Writing your own Java I/O Decorator p. 102 Tools for your Design Toolbox p. 105 Exercise Solutions p. 106 The Factory Pattern Baking with OO Intro to Design Patterns Welcome to Design Patterns: Someone has already solved your problems The SimUDuck app p. 2 Joe thinks about inheritance... p. 5 How about an interface? p. 6 The one constant in

More information

Topics. Software Process. Agile. Requirements. Basic Design. Modular Design. Design Patterns. Testing. Quality. Refactoring.

Topics. Software Process. Agile. Requirements. Basic Design. Modular Design. Design Patterns. Testing. Quality. Refactoring. CS310 - REVIEW Topics Process Agile Requirements Basic Design Modular Design Design Patterns Testing Quality Refactoring UI Design How these things relate Process describe benefits of using a software

More information

Design Patterns. An introduction

Design Patterns. An introduction Design Patterns An introduction Introduction Designing object-oriented software is hard, and designing reusable object-oriented software is even harder. Your design should be specific to the problem at

More information

Design Patterns. Dr. Rania Khairy. Software Engineering and Development Tool

Design Patterns. Dr. Rania Khairy. Software Engineering and Development Tool Design Patterns What are Design Patterns? What are Design Patterns? Why Patterns? Canonical Cataloging Other Design Patterns Books: Freeman, Eric and Elisabeth Freeman with Kathy Sierra and Bert Bates.

More information

What is Design Patterns?

What is Design Patterns? Paweł Zajączkowski What is Design Patterns? 1. Design patterns may be said as a set of probable solutions for a particular problem which is tested to work best in certain situations. 2. In other words,

More information

A Primer on Design Patterns

A Primer on Design Patterns A Primer on Design Patterns First Edition Rahul Batra This book is for sale at http://leanpub.com/aprimerondesignpatterns This version was published on 2016-03-23 This is a Leanpub book. Leanpub empowers

More information

SWEN425 DESIGN PATTERNS

SWEN425 DESIGN PATTERNS T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON EXAMINATIONS 2011 END OF YEAR SWEN425 DESIGN PATTERNS Time Allowed: 3 Hours Instructions:

More information

SYLLABUS CHAPTER - 1 [SOFTWARE REUSE SUCCESS FACTORS] Reuse Driven Software Engineering is a Business

SYLLABUS CHAPTER - 1 [SOFTWARE REUSE SUCCESS FACTORS] Reuse Driven Software Engineering is a Business Contents i UNIT - I UNIT - II UNIT - III CHAPTER - 1 [SOFTWARE REUSE SUCCESS FACTORS] Software Reuse Success Factors. CHAPTER - 2 [REUSE-DRIVEN SOFTWARE ENGINEERING IS A BUSINESS] Reuse Driven Software

More information

Software Design Patterns. Background 1. Background 2. Jonathan I. Maletic, Ph.D.

Software Design Patterns. Background 1. Background 2. Jonathan I. Maletic, Ph.D. Software Design Patterns Jonathan I. Maletic, Ph.D. Department of Computer Science Kent State University J. Maletic 1 Background 1 Search for recurring successful designs emergent designs from practice

More information

A few important patterns and their connections

A few important patterns and their connections A few important patterns and their connections Perdita Stevens School of Informatics University of Edinburgh Plan Singleton Factory method Facade and how they are connected. You should understand how to

More information

Plan. A few important patterns and their connections. Singleton. Singleton: class diagram. Singleton Factory method Facade

Plan. A few important patterns and their connections. Singleton. Singleton: class diagram. Singleton Factory method Facade Plan A few important patterns and their connections Perdita Stevens School of Informatics University of Edinburgh Singleton Factory method Facade and how they are connected. You should understand how to

More information

Advanced C++ Programming Workshop (With C++11, C++14, C++17) & Design Patterns

Advanced C++ Programming Workshop (With C++11, C++14, C++17) & Design Patterns Advanced C++ Programming Workshop (With C++11, C++14, C++17) & Design Patterns This Advanced C++ Programming training course is a comprehensive course consists of three modules. A preliminary module reviews

More information

Design Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1

Design Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1 What is a Design Pattern? Each pattern Describes a problem which occurs over and over again in our environment,and then describes the core of the problem Novelists, playwrights and other writers rarely

More information

1 Software Architecture

1 Software Architecture Some buzzwords and acronyms for today Software architecture Design pattern Separation of concerns Single responsibility principle Keep it simple, stupid (KISS) Don t repeat yourself (DRY) Don t talk to

More information

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1 Ingegneria del Software Corso di Laurea in Informatica per il Management Design Patterns part 1 Davide Rossi Dipartimento di Informatica Università di Bologna Pattern Each pattern describes a problem which

More information

Nat. Thomas Software Engineering Telephonics Inc. Long Island IEEE Lecture Series

Nat. Thomas Software Engineering Telephonics Inc. Long Island IEEE Lecture Series Nat. Thomas Software Engineering Telephonics Inc. Long Island IEEE Lecture Series 10/19/05 Software Design Patterns 1 Software Design Patterns Agenda What are they? Why are they important? Pattern Taxonomy

More information

The GoF Design Patterns Reference

The GoF Design Patterns Reference The GoF Design Patterns Reference Version.0 / 0.0.07 / Printed.0.07 Copyright 0-07 wsdesign. All rights reserved. The GoF Design Patterns Reference ii Table of Contents Preface... viii I. Introduction....

More information

Design patterns. OOD Lecture 6

Design patterns. OOD Lecture 6 Design patterns OOD Lecture 6 Next lecture Monday, Oct 1, at 1:15 pm, in 1311 Remember that the poster sessions are in two days Thursday, Sep 27 1:15 or 3:15 pm (check which with your TA) Room 2244 + 2245

More information

Software Design Patterns. Aliaksei Syrel

Software Design Patterns. Aliaksei Syrel Software Design Patterns Aliaksei Syrel 1 Pattern types Creational Patterns Behavioural Patterns Structural Patterns 2 Creational Patterns Creational design patterns deal with object creation mechanisms,

More information

Design Patterns. (and anti-patterns)

Design Patterns. (and anti-patterns) Design Patterns (and anti-patterns) Design Patterns The Gang of Four defined the most common object-oriented patterns used in software. These are only the named ones Lots more variations exist Design Patterns

More information

Lecture 20: Design Patterns II

Lecture 20: Design Patterns II Lecture 20: Design Patterns II Software System Design and Implementation ITCS/ITIS 6112/8112 001 Fall 2008 Dr. Jamie Payton Department of Computer Science University of North Carolina at Charlotte Nov.

More information

Lectures 24 and 25 Introduction to Architectural Styles and Design Patterns

Lectures 24 and 25 Introduction to Architectural Styles and Design Patterns Lectures 24 and 25 Introduction to Architectural Styles and Design Patterns Software Engineering ITCS 3155 Fall 2008 Dr. Jamie Payton Department of Computer Science University of North Carolina at Charlotte

More information

Keywords: Abstract Factory, Singleton, Factory Method, Prototype, Builder, Composite, Flyweight, Decorator.

Keywords: Abstract Factory, Singleton, Factory Method, Prototype, Builder, Composite, Flyweight, Decorator. Comparative Study In Utilization Of Creational And Structural Design Patterns In Solving Design Problems K.Wseem Abrar M.Tech., Student, Dept. of CSE, Amina Institute of Technology, Shamirpet, Hyderabad

More information

An Introduction to Patterns

An Introduction to Patterns An Introduction to Patterns Robert B. France Colorado State University Robert B. France 1 What is a Pattern? - 1 Work on software development patterns stemmed from work on patterns from building architecture

More information

Creational Design Patterns

Creational Design Patterns Creational Design Patterns Creational Design Patterns Structural Design Patterns Behavioral Design Patterns GoF Design Pattern Categories Purpose Creational Structural Behavioral Scope Class Factory Method

More information

Application Architectures, Design Patterns

Application Architectures, Design Patterns Application Architectures, Design Patterns Martin Ledvinka martin.ledvinka@fel.cvut.cz Winter Term 2017 Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term

More information

Tuesday, October 4. Announcements

Tuesday, October 4. Announcements Tuesday, October 4 Announcements www.singularsource.net Donate to my short story contest UCI Delta Sigma Pi Accepts business and ICS students See Facebook page for details Slide 2 1 Design Patterns Design

More information

A Case Study of Gang of Four (GoF) Patterns: Part 3

A Case Study of Gang of Four (GoF) Patterns: Part 3 A Case Study of Gang of Four (GoF) Patterns: Part 3 d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Professor of Computer Science Institute for Software Integrated Systems Vanderbilt University

More information

Think of drawing/diagramming editors. ECE450 Software Engineering II. The problem. The Composite pattern

Think of drawing/diagramming editors. ECE450 Software Engineering II. The problem. The Composite pattern Think of drawing/diagramming editors ECE450 Software Engineering II Drawing/diagramming editors let users build complex diagrams out of simple components The user can group components to form larger components......which

More information

Socket attaches to a Ratchet. 2) Bridge Decouple an abstraction from its implementation so that the two can vary independently.

Socket attaches to a Ratchet. 2) Bridge Decouple an abstraction from its implementation so that the two can vary independently. Gang of Four Software Design Patterns with examples STRUCTURAL 1) Adapter Convert the interface of a class into another interface clients expect. It lets the classes work together that couldn't otherwise

More information

INSTITUTE OF AERONAUTICAL ENGINEERING

INSTITUTE OF AERONAUTICAL ENGINEERING INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad -500 0 COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Course Name : DESIGN PATTERNS Course Code : A7050 Class : IV B. Tech

More information

Design Patterns. Observations. Electrical Engineering Patterns. Mechanical Engineering Patterns

Design Patterns. Observations. Electrical Engineering Patterns. Mechanical Engineering Patterns Introduction o to Patterns and Design Patterns Dept. of Computer Science Baylor University Some slides adapted from slides by R. France and B. Tekinerdogan Observations Engineering=Problem Solving Many

More information

Ownership in Design Patterns. Master's Thesis Final Presentation Stefan Nägeli

Ownership in Design Patterns. Master's Thesis Final Presentation Stefan Nägeli Ownership in Design Patterns Master's Thesis Final Presentation Stefan Nägeli 07.02.06 Overview Status Quo Pattern Overview Encountered Problems applying UTS Pros and Cons compared to other systems UTS

More information

Patterns. Erich Gamma Richard Helm Ralph Johnson John Vlissides

Patterns. Erich Gamma Richard Helm Ralph Johnson John Vlissides Patterns Patterns Pattern-based engineering: in the field of (building) architecting and other disciplines from 1960 s Some software engineers also started to use the concepts Become widely known in SE

More information

Welcome to Design Patterns! For syllabus, course specifics, assignments, etc., please see Canvas

Welcome to Design Patterns! For syllabus, course specifics, assignments, etc., please see Canvas Welcome to Design Patterns! For syllabus, course specifics, assignments, etc., please see Canvas What is this class about? While this class is called Design Patterns, there are many other items of critical

More information

Design Patterns. SE3A04 Tutorial. Jason Jaskolka

Design Patterns. SE3A04 Tutorial. Jason Jaskolka SE3A04 Tutorial Jason Jaskolka Department of Computing and Software Faculty of Engineering McMaster University Hamilton, Ontario, Canada jaskolj@mcmaster.ca November 18/19, 2014 Jason Jaskolka 1 / 35 1

More information

CSCI Object Oriented Design: Frameworks and Design Patterns George Blankenship. Frameworks and Design George Blankenship 1

CSCI Object Oriented Design: Frameworks and Design Patterns George Blankenship. Frameworks and Design George Blankenship 1 CSCI 6234 Object Oriented Design: Frameworks and Design Patterns George Blankenship Frameworks and Design George Blankenship 1 Background A class is a mechanisms for encapsulation, it embodies a certain

More information

Software Reengineering Refactoring To Patterns. Martin Pinzger Delft University of Technology

Software Reengineering Refactoring To Patterns. Martin Pinzger Delft University of Technology Software Reengineering Refactoring To Patterns Martin Pinzger Delft University of Technology Outline Introduction Design Patterns Refactoring to Patterns Conclusions 2 The Reengineering Life-Cycle (1)

More information

The Design Patterns Matrix From Analysis to Implementation

The Design Patterns Matrix From Analysis to Implementation The Design Patterns Matrix From Analysis to Implementation This is an excerpt from Shalloway, Alan and James R. Trott. Design Patterns Explained: A New Perspective for Object-Oriented Design. Addison-Wesley

More information

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico Modellistica Medica Maria Grazia Pia INFN Genova Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico 2002-2003 Lezione 9 OO modeling Design Patterns Structural Patterns Behavioural Patterns

More information

Plan. Design principles: laughing in the face of change. What kind of change? What are we trying to achieve?

Plan. Design principles: laughing in the face of change. What kind of change? What are we trying to achieve? Plan Design principles: laughing in the face of change Perdita Stevens School of Informatics University of Edinburgh What are we trying to achieve? Review: Design principles you know from Inf2C-SE Going

More information

Design Patterns. Hausi A. Müller University of Victoria. Software Architecture Course Spring 2000

Design Patterns. Hausi A. Müller University of Victoria. Software Architecture Course Spring 2000 Design Patterns Hausi A. Müller University of Victoria Software Architecture Course Spring 2000 1 Motivation Vehicle for reasoning about design or architecture at a higher level of abstraction (design

More information

administrivia today UML start design patterns Tuesday, September 28, 2010

administrivia today UML start design patterns Tuesday, September 28, 2010 administrivia Assignment 2? promise to get past assignment 1 back soon exam on monday review slides are posted your responsibility to review covers through last week today UML start design patterns 1 Unified

More information

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar Design Patterns MSc in Communications Software Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie

More information

Applying Some Gang of Four Design Patterns CSSE 574: Session 5, Part 3

Applying Some Gang of Four Design Patterns CSSE 574: Session 5, Part 3 Applying Some Gang of Four Design Patterns CSSE 574: Session 5, Part 3 Steve Chenoweth Phone: Office (812) 877-8974 Cell (937) 657-3885 Email: chenowet@rose-hulman.edu Gang of Four (GoF) http://www.research.ibm.com/designpatterns/pubs/ddj-eip-award.htm

More information

Chapter 8, Design Patterns Visitor

Chapter 8, Design Patterns Visitor Chapter 8, Design Patterns Visitor Using UML, Patterns, and Java Object-Oriented Software Engineering Pattern A Pattern Taxonomy Structural Pattern Behavioral Pattern Creational Pattern Composite Decorator

More information

Overview of Patterns: Introduction

Overview of Patterns: Introduction : Introduction d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Professor of Computer Science Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA Introduction

More information

Applying Design Patterns to accelerate development of reusable, configurable and portable UVCs. Accellera Systems Initiative 1

Applying Design Patterns to accelerate development of reusable, configurable and portable UVCs. Accellera Systems Initiative 1 Applying Design Patterns to accelerate development of reusable, configurable and portable UVCs. Accellera Systems Initiative 1 About the presenter Paul Kaunds Paul Kaunds is a Verification Consultant at

More information

Applying the Decorator Design Pattern

Applying the Decorator Design Pattern Applying the Decorator Design Pattern Trenton Computer Festival Professional Seminars Michael P. Redlich (908) 730-3416 michael.p.redlich@exxonmobil.com About Myself Degree B.S. in Computer Science Rutgers

More information

Trusted Components. Reuse, Contracts and Patterns. Prof. Dr. Bertrand Meyer Dr. Karine Arnout

Trusted Components. Reuse, Contracts and Patterns. Prof. Dr. Bertrand Meyer Dr. Karine Arnout 1 Last update: 2 November 2004 Trusted Components Reuse, Contracts and Patterns Prof. Dr. Bertrand Meyer Dr. Karine Arnout 2 Lecture 12: Componentization Agenda for today 3 Componentization Componentizability

More information

CS251 Software Engineering Lectures 18: Intro to DP

CS251 Software Engineering Lectures 18: Intro to DP و ابتغ فيما آتاك هللا الدار اآلخرة و ال تنس نصيبك من الدنيا CS251 Software Engineering Lectures 18: Intro to DP Slides by Rick Mercer, Christian Ratliff, Oscar Nierstrasz and others 1 Outline Introduction

More information

Designing and Writing a Program. Divide and Conquer! The Design-Code-Debug Cycle. Documentation is Code. Pair Programming 3/8/2012

Designing and Writing a Program. Divide and Conquer! The Design-Code-Debug Cycle. Documentation is Code. Pair Programming 3/8/2012 CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims Lecture 13: Designing, Coding, and Documenting Designing and Writing a Program Don't sit down at the terminal

More information

CS560. Lecture: Design Patterns II Includes slides by E. Gamma et al., 1995

CS560. Lecture: Design Patterns II Includes slides by E. Gamma et al., 1995 CS560 Lecture: Design Patterns II Includes slides by E. Gamma et al., 1995 Classification of GoF Design Pattern Creational Structural Behavioural Factory Method Adapter Interpreter Abstract Factory Bridge

More information

Pro Objective-C Design Patterns for ios

Pro Objective-C Design Patterns for ios Pro Objective-C Design Patterns for ios Carlo Chung Contents Contents at a Glance About the Author About the Technical Reviewer Acknowledgments Preface x xi xii xiii Part I: Getting Your Feet Wet 1 Chapter

More information

DESIGNING, CODING, AND DOCUMENTING

DESIGNING, CODING, AND DOCUMENTING DESIGNING, CODING, AND DOCUMENTING Lecture 16 CS2110 Fall 2013 Designing and Writing a Program 2 Don't sit down at the terminal immediately and start hacking Design stage THINK first about the data you

More information

Software Eningeering. Lecture 9 Design Patterns 2

Software Eningeering. Lecture 9 Design Patterns 2 Software Eningeering Lecture 9 Design Patterns 2 Patterns covered Creational Abstract Factory, Builder, Factory Method, Prototype, Singleton Structural Adapter, Bridge, Composite, Decorator, Facade, Flyweight,

More information

MVC. Model-View-Controller. Design Patterns. Certain programs reuse the same basic structure or set of ideas

MVC. Model-View-Controller. Design Patterns. Certain programs reuse the same basic structure or set of ideas MVC -- Design Patterns Certain programs reuse the same basic structure or set of ideas These regularly occurring structures have been called Design Patterns Design Patterns Design Patterns: Elements of

More information

Design Patterns Lecture 2

Design Patterns Lecture 2 Design Patterns Lecture 2 Josef Hallberg josef.hallberg@ltu.se 1 Patterns covered Creational Abstract Factory, Builder, Factory Method, Prototype, Singleton Structural Adapter, Bridge, Composite, Decorator,

More information

Improve Your SystemVerilog OOP Skills

Improve Your SystemVerilog OOP Skills 1 Improve Your SystemVerilog OOP Skills By Learning Principles and Patterns Jason Sprott Verilab Email: jason.sprott@verilab.com www.verilab.com Experts in SV Learn Design Patterns 2 Look, you don t need

More information

design patterns FOR B.tech (jntu - hyderabad & kakinada) (IV/I - CSE AND IV/II - IT) CONTENTS 1.1 INTRODUCTION TO DESIGN PATTERNS TTERNS... TTERN?...

design patterns FOR B.tech (jntu - hyderabad & kakinada) (IV/I - CSE AND IV/II - IT) CONTENTS 1.1 INTRODUCTION TO DESIGN PATTERNS TTERNS... TTERN?... Contents i design patterns FOR B.tech (jntu - hyderabad & kakinada) (IV/I - CSE AND IV/II - IT) CONTENTS UNIT - I [CH. H. - 1] ] [INTRODUCTION TO ]... 1.1-1.32 1.1 INTRODUCTION TO... 1.2 1.2 WHAT T IS

More information

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico Modellistica Medica Maria Grazia Pia INFN Genova Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico 2002-2003 Lezione 8 OO modeling Design Patterns Introduction Creational Patterns Software

More information

What is Design Patterns?

What is Design Patterns? Paweł Zajączkowski What is Design Patterns? 1. Design patterns may be said as a set of probable solutions for a particular problem which is tested to work best in certain situations. 2. In other words,

More information

Singleton Pattern Creational

Singleton Pattern Creational Singleton Pattern Creational Intent» Ensure a class has only one instance» Provide a global point of access Motivation Some classes must only have one instance file system, window manager Applicability»

More information

A Reconnaissance on Design Patterns

A Reconnaissance on Design Patterns A Reconnaissance on Design Patterns M.Chaithanya Varma Student of computer science engineering, Sree Vidhyanikethan Engineering college, Tirupati, India ABSTRACT: In past decade, design patterns have been

More information