[Type here] Implementing Design Patterns 1 Assignment - Design Pattern Objectives Use design patterns to build the application General (Note the use of REQUIREMENTS ) 1. You MUST to create 5 design...

design pattern


[Type here] Implementing Design Patterns 1 Assignment - Design Pattern Objectives Use design patterns to build the application General (Note the use of REQUIREMENTS ) 1. You MUST to create 5 design patterns for the application specified below (each worth 8 points). 2. You MUST use Java! 3. You MAY use Astah to generate the skeleton Java code from the UML. You might want to incorporate the “Class Description” tables into your UML before generating code. If you do, add the UML files to the project upload (with your name in a comment block). 4. You do NOT: a) need to meet all the functional requirements specified in Task 1 but the general idea should be visible b) have to have a running/working application (but it should not have compiler errors or warnings!). 5. We will grade you based on the code that you’ve written. 6. Please indicate (as comments in submission box on Canvas) which design patterns you implemented and the class file or piece of code where it is implemented (this documentation is important and will be graded!). As stated before, you do not have to implement all the requirements and you can choose any 4 design patterns for task 1 that you see fit. The HINTS might help you. You are relatively free of how to do things. Please mark where you see your Design Patterns in your code. This is relatively coding intensive again, start early it will take a while to figure things out. Introduce Design Patterns (40) In this homework we implemented five design patterns into the Homework Assignment Distribution and Collection System (HACS). The five design patterns, which are implemented within the HACS systems, are Façade, Bridge, FactoryMethod, Iterator, and Visitor. In the following sections, a brief description of the patterns and the detail implementation of the patterns are presented. 1. Façade The façade pattern can make the task of accessing a large number of modules much simpler by providing an additional interface layer. In the implementation of the HACS system, the façade lies in top of all the interfaces and modules. The façade object provides a single interface to the more general facilities of other subsystems. The benefits offered by façade are as follows. Edited with the trial version of Foxit Advanced PDF Editor To remove this notice, visit: www.foxitsoftware.com/shopping http://www.foxitsoftware.com/shopping [Type here] Implementing Design Patterns 2 1. It shields the subsystem components to the HACS system. For example, in the HACS system, the main function does not have to deal with all the subsystem components. Instead, it just passes the control to the façade object and the façade object wraps up all the subsystem components. 2. The façade object eliminates the dependencies between objects. Figure 1 shows the structure of the façade object and its subsystem classes. Table 1 shows the class description of façade object. Edited with the trial version of Foxit Advanced PDF Editor To remove this notice, visit: www.foxitsoftware.com/shopping http://www.foxitsoftware.com/shopping [Type here] Implementing Design Patterns 3 Edited with the trial version of Foxit Advanced PDF Editor To remove this notice, visit: www.foxitsoftware.com/shopping http://www.foxitsoftware.com/shopping [Type here] Implementing Design Patterns 4 Bridge The Bridge pattern affects the load menu option in the HACS system. When a user logs in, the bridge will help to load the appropriate menu for either student or instructor. Furthermore, the menu should be different depends on which kind of course is selected, i.e., high-level course or low-level course. This feature is implemented by bridge pattern. In the bridge that is implemented in HACS, the CourseMenu is the implementor class hierarchy, which has two subclasses named HighLevelCourseMenu and LowLevelCourseMenu, and the Person is the abstraction class hierarchy which has two subclasses named Instructor and Student. The benefits of bridge pattern are that the implementation is not bound permanently to an interface. The implementation of an abstraction can be configured at runtime. For example, the ‘real’ user interface of the CourseMenu is configured at runtime depends on the type of the course (high level course or low-level course) and the type of the user (student or instructor). And it is easy to extend the functionality that could be done by the load menu option. For example, if one other type of user or course is added, we can extend the abstraction (person) or implementor (courseMenu) accordingly and independently. Without bridge, we would have to instantiate 4 subclasses for two kinds of user and two kinds of courses. Even worse, if we add one type of course, we would have to add two subclasses for both instructor and student. Figure 2 illustrates the structure of the Bridge pattern in this system. Table 2 shows the class description of Bridge pattern in this implementation. Edited with the trial version of Foxit Advanced PDF Editor To remove this notice, visit: www.foxitsoftware.com/shopping http://www.foxitsoftware.com/shopping [Type here] Implementing Design Patterns 5 Edited with the trial version of Foxit Advanced PDF Editor To remove this notice, visit: www.foxitsoftware.com/shopping http://www.foxitsoftware.com/shopping [Type here] Implementing Design Patterns 6 Factory Method The Factory Method pattern enables the subclasses to decide which class to instantiate. In the HACS system, the Factory Method pattern is implemented when the CourseMenu is loaded. The CourseMenu depends on course level and user type. The Factory Method will determine which class to instantiate. The benefit of Factory Method is to eliminate the need to bind application specific classes into the code. The code only deals with the Product interface (CourseMenu in this system), so it can deal with any ConcreteProduct class (HighLevelCourseMenu and LowLevelCourseMenu in this system). Figure 3 illustrates the structure of factory method implemented in this system. Table 3 shows the class description of Factory Method. Edited with the trial version of Foxit Advanced PDF Editor To remove this notice, visit: www.foxitsoftware.com/shopping http://www.foxitsoftware.com/shopping [Type here] Implementing Design Patterns 7 Iterator The Iterator pattern is implemented as a means for distributing the grade report for the students. The Interator class defines an interface for accessing the list’s elements without exposing its internal structure. The SolutionIterator is implemented as an Iterator to the SolutionList class. It simplifies the Aggregate interface and supports variations in the traversal Edited with the trial version of Foxit Advanced PDF Editor To remove this notice, visit: www.foxitsoftware.com/shopping http://www.foxitsoftware.com/shopping [Type here] Implementing Design Patterns 8 of an aggregate. Figure 4 illustrates the structure of Iterator Pattern in the HACS system. Table 4 lists the class description of the Iterator pattern. Edited with the trial version of Foxit Advanced PDF Editor To remove this notice, visit: www.foxitsoftware.com/shopping http://www.foxitsoftware.com/shopping [Type here] Implementing Design Patterns 9 Visitor The purpose of the Visitor Pattern is to encapsulate an operation that you want to perform on the elements of a data structure. In this way, you can change the operation being performed on a structure without the need of changing the classes of the elements that you are operating on. Using a Visitor pattern allows you to decouple the classes for the data structure and the algorithms used upon them. The benefit of Visitor is that Visitor makes adding new operation easy. Each node in the data structure "accepts" a Visitor, which sends a message to the Visitor, which includes the node's class. The visitor will then execute its algorithm for that element. In our implementation of HACS system, ReminderVisitor provides the Visitor capacity. Figure 5 illustrates the structure of Visitor pattern in HACS system. Table 5 lists the class description of Visitor Pattern. Edited with the trial version of Foxit Advanced PDF Editor To remove this notice, visit: www.foxitsoftware.com/shopping http://www.foxitsoftware.com/shopping [Type here] Implementing Design Patterns 10 Edited with the trial version of Foxit Advanced PDF Editor To remove this notice, visit: www.foxitsoftware.com/shopping http://www.foxitsoftware.com/shopping [Type here] Implementing Design Patterns 11 Class Diagram Now we integrate all the patterns mentioned in the previous sections and all other classes that are used in the implementation of HACS system to make the Class Diagram for the whole system. Figure 6 shows the Class Diagram for the HACS system. All the patterns are highlighted with boxes. Edited with the trial version of Foxit Advanced PDF Editor To remove this notice, visit: www.foxitsoftware.com/shopping http://www.foxitsoftware.com/shopping [Type here] Implementing Design Patterns 12 Additional information Create a “database” with the following data: This will be the test set for your data… Refer to the InsInfor.txt, StuInfo.txt, CourseInfo.txt, UserCourse.txt for detail information. Submission You need to submit 1. A zip file assignDP..zip (asurite should be replaced by your asurite, for me it would be assignDP.mjfindle.zip). Make sure you commented your code well and marked where you see your Design Patterns. Edited with the trial version of Foxit Advanced PDF Editor To remove this notice, visit: www.foxitsoftware.com/shopping http://www.foxitsoftware.com/shopping
Oct 12, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here