A4 Explain how the Visitor design pattern works (4 marks)

Similar documents
Model answers/marking scheme in bold, additional comments in bold italic.

COMP19612 exam performance feedback 2014

Exam in TDDB84: Design Patterns,

Tuesday, October 4. Announcements

CSE 70 Final Exam Fall 2009

BCS THE CHARTERED INSTITUTE FOR IT. BCS Higher Education Qualifications BCS Level 6 Professional Graduate Diploma in IT EXAMINERS' REPORT

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

be used for more than one use case (for instance, for use cases Create User and Delete User, one can have one UserController, instead of two separate

From Design Patterns: Elements of Reusable Object Oriented Software. Read the sections corresponding to patterns covered in the following slides.

EINDHOVEN UNIVERSITY OF TECHNOLOGY

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

ADVANCED SOFTWARE DESIGN LECTURE 7 GRASP

drawobject Circle draw

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

Using Design Patterns in Java Application Development

Design Patterns. CSC207 Fall 2017

A few important patterns and their connections

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

SDC Design patterns GoF

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

The Design Patterns Matrix From Analysis to Implementation

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

Design patterns. Jef De Smedt Beta VZW

Design Patterns Revisited

18.1 Definitions and General OO Principles

Unit Wise Questions. Unit-1 Concepts

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

Design Patterns. CSC207 Winter 2017

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

CSE 12 Abstract Syntax Trees

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

Student Performance Q&A:

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

Object-Oriented Design

Final Exam Review (extended)

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

GRASP Design Patterns A.A. 2018/2019

17. GRASP: Designing Objects with Responsibilities

Responsibilities. Using several specific design principles to guide OO design decisions.

Last Lecture. Lecture 26: Design Patterns (part 2) State. Goals of Lecture. Design Patterns

Object Oriented Design and Programming Revision

Design Patterns: Structural and Behavioural

Idioms and Design Patterns. Martin Skogevall IDE, Mälardalen University

Object Oriented Paradigm

BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT. Object Oriented Programming

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

(Refer Slide Time: 4:00)

Final Exam. Final Exam Review. Ch 1: Introduction: Object-oriented analysis, design, implementation. Exam Format

UNIT I Introduction to Design Patterns

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value

Lectures 24 and 25 Introduction to Architectural Styles and Design Patterns

C++ for Java Programmers

DESIGN PATTERN - INTERVIEW QUESTIONS

Object-Oriented Oriented Programming

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

Object-Oriented Design

Design Patterns. An introduction

MSO Object Creation Singleton & Object Pool

MTAT Software Engineering. Written Exam 17 January Start: 9:15 End: 11:45

Objects and Classes. Amirishetty Anjan Kumar. November 27, Computer Science and Engineering Indian Institue of Technology Bombay

MTAT Software Engineering. Written Exam 10 January Start: 9:15 End: 11:45

Design Patterns. Comp2110 Software Design. Department of Computer Science Australian National University. Second Semester

Proofwriting Checklist

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

SE310 Analysis and Design of Software Systems

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Exam Questions. Object-Oriented Design, IV1350. Maximum exam score is 100, grade limits are as follows. Score Grade 90 A 80 B 70 C 60 D 50 E

What is Design Patterns?

Module Contact: Dr Tony Bagnall, CMP Copyright of the University of East Anglia Version 1

MSO Exam November 7, 2016, 13:30 15:30, Educ-Gamma

Expanding Our Horizons. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 9 09/25/2011

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

Introduction to Software Engineering: Object Design I Reuse & Patterns

Agile Architecture. The Why, the What and the How

CPSC 310: Sample Final Exam Study Questions 2014S1 (These are in addition to the Study Questions listed at the end of some lectures)

SOFTWARE ENGINEERING SOFTWARE DESIGN. Saulius Ragaišis.

MSO Lecture 12. Wouter Swierstra (adapted by HP) October 26, 2017

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

Object-Oriented Design I

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

Bridge Pattern. Used to decouple an abstraction from its implementation so that the two can vary independently

Class diagrams and architectural design

C++ (Non for C Programmer) (BT307) 40 Hours

Logistics. Final Exam on Friday at 3pm in CHEM 102

UML class diagrams. Nigel Goddard. School of Informatics University of Edinburgh

Abstraction. Design fundamentals in OO Systems. Fundamental Software Development Principles

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

Chapter 1 Getting Started

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

CSE 401/M501 Compilers

THE BCS PROFESSIONAL EXAMINATION BCS Level 5 Diploma in IT September 2017 EXAMINERS REPORT

SE 2 [CS 446, CS 646, ECE 452, SE 464] Software Design & Architecture Spring 2011 MIDTERM

The University of Nottingham

Review Software Engineering October, 7, Adrian Iftene

Last Lecture. Lecture 17: Design Patterns (part 2) Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 4448/ Spring Semester, 2005

1: Introduction to Object (1)

SWEN425 DESIGN PATTERNS

The GoF Design Patterns Reference

Difference Between Dates Case Study 2002 M. J. Clancy and M. C. Linn

Design Patterns. Paul Jackson. School of Informatics University of Edinburgh

Transcription:

COMP61532 exam Performance feedback Original marking scheme in bold, additional comments in bold italic. Section A In general the level of English was poor, spelling and grammar was a problem in most cases. Some answers made no sense at all. For A1, the overall performance for the students was impressive. Most students have demonstrated their knowledge and understanding of the P4eb approach. However, there seems to be confusion between how students understood the terms business interactions and business patterns. Some students have used the two terms interchangeably while others did not. In A2 there was a major disparity in students performances. About 60% have performed exceptionally well, while the rest performed poorly. A number of students have failed to answer the question, and gave unnecessary information instead. Most students understood the fundamental assumptions of the P4eb approach and had the at least an idea of the steps in this approach, but very few attempted the last part of the question for associating the steps with their target architectural layers. A3 Explain why design patterns are a tool for communication. Your answer should state who is doing the communicating and should include two specific examples of design patterns. (4 marks) Design patterns enable quick communication between experienced developers They also allow experienced developers to communicate best practice to inexperienced ones. An example of the former is do you think we should use a Factory to create the Adaptors? An example of the latter is that you might draw a class diagram to show the Strategy pattern, and giving an example of its use. A number of people misunderstood the use of the word communication here. It should be obvious that we re talking about people, rather than objects, communicating because the questions says who is doing the communicating A4 Explain how the Visitor design pattern works (4 marks) Visitor allows us to manipulate an object structure with code outside of that structure. A visitor class has a method visitc for every class to be visited. Each such class has a single extra method accept(visitor) which runs the relevant visitor method. An object structure may have multiple visitors, in which case there is an interface which all the Visitor classes implement and the classes in the object structure still need only a single accept method. A lot of people were caught out by this and didn t really know the pattern. A5 Under what circumstances is it appropriate to use the Visitor pattern? (2 marks)

Visitor inverts the normal OO structure and collects the whole of an algorithm in one class. This is appropriate when the object structure is stable but the algorithms to be applied to it are complex and liable to change. Otherwise it s best to make each class responsible for its part of the algorithm in the normal OO way. I gave marks here for anybody who got the right general idea. Section B Students seemed to be remembering/imagining actors and use cases instead of analyzing the given scenario. This could be explained in two ways: 1) either by the fact that the exam is not suitable for online assessment or 2) the software tool is not suitable for the design type of exam. In general students' answers seemed to be characterised by at least one of the following attributes: unfocused, unorganized, short and lacking detail. None of the students managed to offer a complete and correct description of their model. None of the students produced any convincing arguments in favour of their solution. The lack of graphical representation is a major issue for this particular exam, as it forces the student to detail the solution using natural language. As a consequence most of the time answers were shallow, inaccurate and difficult to read/understand due to a poor command of written English language. John adds: the comments about being unfocussed etc. and English language issues also apply to section C. Section C Answer ONE question from this section. The questions relate to the design of an online assessment system such as the one you are using. C1 a) The server returns copies of the question paper created by a Factory which is a Singleton. Explain this statement and how it relates to the use of design patterns for communication. (4 marks) Instead of creating copies of QuestionPaper objects directly, this task is delegated to a separate factory class, which will create them. [1] This provides a separation of concerns and makes it easy to create exam papers flexibly, for instance we might randomly or adaptively select from a question bank, possible giving different papers to different students. [1] We only even need one instance of this factory class, hence it s a singleton. [1] Design patterns provide a common language for so for instance here an important design decision is conveyed in a single sentence [1]

Note that the fact that the factory is a singleton does NOT mean all the question papers are the same. If anything the use of a factory suggests the opposed (as above) although there is nothing explicit in the question about the properties of question papers. b) Show the important elements of this class in Java syntax (4 marks) public class QuestionPaperFactory { private static QuestionPaperFactory instance; [1] // Constructor is private so we can only create instances internally private QuestionPaperFactory() { } [1 bonus] // Eager instantiation is also acceptable public static QuestionPaperFactory getinstance() { [1] if (instance == null) instance = new QuestionPaperFactory(); [1] return instance; // Methods to create question papers. [or similar, 1] } } Note that it s the Factory which is the Singleton, not the question paper (by definition there must be multiple instances of that - they even reside on different physical machines). c) Suppose the application is being extended so that it will accept question papers written in a variety of different formats an convert those to the format used by the exam software. Draw a UML class diagrams showing how the Adapter pattern can be used to organise this part of the application. (4 marks) Abstract Adapter class [1] Concrete adapter subclasses [1] Sensible names [1] Correct use of UML notation [1] Note; in practice there will be many variations and this simplistic marking scheme will not always work. It turns out that I unintentionally made this question too easy, as it s essentially the example of Adapter I used in the course. As a result I marked it strictly, in particular I only gave full marks for solutions which showed that the adapter classes all have the same interface (derived from the AbsctractAdatper class) while the classes being adapted have different interfaces.

d) Given an example (not one given in the course) of another application in which the adapter pattern could play a useful role. Marks for any sensible example with the role of the adapter clearly explained. E.g. adapting between different product description formats in a retail application. There were a lot of very good answers. I gave full marks only to those answers which showed clearly how the full adapter pattern (with multiple concrete adapters implementing a common interface) would be useful, as opposed to merely a single adapter class. e) Explain how the Factory and Adapter patterns are related to GRASP principles. For full marks you should include four different GRASP principles in your answer. (4 marks) High cohesion, e.g a Factory creates objects and does nothing else. Low coupling, e.g. Adapter decouples code within the application from external question formats Both are Pure Fabrications they are there to improve the design and are not related to domain classes Adapter makes use of Polymorphism to provide Protected Variations 1 mark for each, or for other valid points C2 When an exam is taking place, student activity is monitored by a tool, which shows a dynamically updated table of the students taking the exam, with information such as when the most recent backup occurred for each student, and whether any students have attempted to cheat by accessing applications or web pages other than the exam. The monitoring tool works by sending HTTP messages to the server, receiving data in response, so to a firewall it looks just like a web browser. In other words, the tool is polling the server at intervals for batches of information, rather than the server providing each piece of information as soon as it s available. a) In the first version of the monitoring tool, there was a 1-1 mapping between exams and invigilator tool instances. It was not possible for one exam to be monitored by many tools, or many exams to be monitored by one tool. Also, we expect in the future to have different types of tools for different users, e.g. invigilators in a room vs. managers overseeing the whole exam process. We might even have different types of servers, e.g. local vs. remote. Explain how the Observer design pattern can be used to remove these restrictions and provide the basis of future developments. (4 marks) The monitoring tool is the Observer and the server the Observable. Hence the tool registers with the server to receive messages, and the server notifies the tool when an event occurs. This provides flexible communication between servers and tools. In

addition, we can have a MonitoringInterface (an ObserverInterface) which different monitoring tools implement, and likewise for servers, giving the full Observer pattern. It s also acceptable to consider the exam clients as the observables, even though the are not directly associated with the monitoring tools as in the normal observer pattern. b) Draw a UML diagram to illustrate the Observer pattern as applied to this situation. 6 marks Diagram should show the above in correct UML notation. Observer/observable 2 marks, register/notify 2 marks, interfaces 2 marks. Max 3 marks if the generic Observer pattern is shown, rather than specifically related to the application. Many people lost marks though misusing the notation, and quite a few didn t really understand Observer. c). In what way does the method of communication between the tool and the server described above require changes to the standard Observer pattern? 2 marks. Normally, notification is per-event, and immediate (a method call). In this case the server must store events until the tool asks for them the opposite way round from the standard pattern. d) Suggest another way in which the Observer pattern could be used in the monitoring tool. 2 marks. The obvious one is in the user interface the Java event model. Could also be used to chain monitoring tools together. e) Briefly suggest how two other design patterns might be used in the monitoring process. 2 marks e.g. Strategy for different monitoring strategies, Proxy for indirect server access, Composite for dealing with the monitoring data hierarchically in a large organisation marks for ay sensible suggestions. f) Explain how the Observer pattern is related to GRASP principles. For full marks you should include four different GRASP principles in your answer. Uses polymorphism. Provides flexibility PV. Low coupling between observers and observables. Likewise high cohesion. Etc. This should have been easy but quite a few people failed to mention 4 GRASP patterns.