50 likes | 165 Views
VOP Exam June 13. 2006. Group 6: Jones Olaiya Ogunduyilemi Knut Tveitane. 3. Visitor Pattern. Used to traverse an object hierarchy, adding functionality to each class of objects (”Elements”) Implemented using Double Dispatch
E N D
VOP Exam June 13. 2006 Group 6: Jones Olaiya OgunduyilemiKnut Tveitane
3. Visitor Pattern • Used to traverse an object hierarchy, adding functionality to each class of objects (”Elements”) • Implemented using Double Dispatch • Elelment classes implement accept(IVisitor v) method which call v.visit(this) • Traversal of lower levels can be handled from the client or from within the visitor class methods • Example: Different ”print” functionality for the object tree in UML Diagram Editor
4. Double Dispatch • Used to achieve ”2-level polymorphy” • Level 1: Client’s choice of functional extension class (”Visitor” in Visitor Pattern) • Level 2: Class of the Element to process • One class per functional extension type • Extension classes implement common interface • Each extension class implement one extension method per Element class to process • Example: Used with Visitor Pattern
8. Interaction-based Testing • Tests interactions between objects • ”White Box” – assumes knowledge of inner workings • Primary object – object to perform test on • Mock objects – proxy objects/stubs for objects the primary object interacts with • Interface based: ”Real” and mock objects must implement the same interface or abstract class • Calls to mock objects (methods and arguments) are examined (using reflection) and compared to expectations • NMock can create and test mock objects
15. Adaptive Object Model • No domain specific classes • Classes define metadata attributes • Property pattern: Object attributes as a collection of property objects • Property class defines name,type and value attributes • Adapts easily to new object types • Custom tools -> user configurable solution • Including object relations and business logic • Tools are domain specific, not the data model