BTEC Level 5 HND Computing Unit 20: Design Patterns Report Analysis

Verified

Added on  2022/02/17

|26
|4542
|15
Report
AI Summary
This report is a comprehensive analysis of design patterns, focusing on their application in advanced programming. It begins with an introduction to design patterns, their importance, and the three main categories: creational, structural, and behavioral. The report then delves into the practical application of the Builder pattern through a case study of a fast-food ordering system, including UML class diagrams and code implementation in C#. The report further explores and compares other design patterns, such as Factory Method and Prototype, evaluating their suitability against the chosen scenario and justifying the selection of the Builder pattern. The document includes detailed diagrams, code snippets, and a comparative table to illustrate the implementation and outcomes. This report is a valuable resource for students studying design patterns and software development, providing insights into their practical application and comparative analysis.
Document Page
ASSIGNMENT 2 FRONT SHEET
Qualification BTEC Level 5 HND Diploma in Computing
Unit number and title Unit 20: Advanced Programming
Submission date Date Received 1st submission
Re-submission Date Date Received 2nd submission
Student Name Student ID
Class Assessor name
Student declaration
I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that
making a false declaration is a form of malpractice.
Student’s signature
Grading grid
P3 P4 M3 M4 D3 D4
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Summative Feedback: Resubmission Feedback:
Grade: Assessor Signature: Date:
Internal Verifier’s Comments:
Signature & Date:
Document Page
Table of Contents
I. Introduction...........................................................................................................................................4
II. Implement code applying design patterns.........................................................................................5
1. P3 Build an application derived from UML class diagrams......................................................................5
2. M3 Develop code that implements a design pattern for a given purpose.................................................7
III. Investigate scenarios with respect to design patterns.....................................................................14
1. P4 Discuss a range of design patterns with relevant examples of creational, structural and behavioral
pattern types........................................................................................................................................................14
a. What is Design Patterns?..........................................................................................................................................14
b. Creational Patterns....................................................................................................................................................14
c. Structural Pattern......................................................................................................................................................18
d. Behavioral Pattern.....................................................................................................................................................21
2. M4 Reconcile the most appropriate design pattern from a range with a series of given scenarios......24
a. Benefits of Pattern Builder............................................................................................................................... 24
b. Differences of builder pattern and other design patterns..................................................................................24
c. Why we choose builder patterns to develop scenario?.....................................................................................25
Bibliography........................................................................................................................................26
Table Of Figures
Figure 1: Car ticket Class diagram................................................................................................................................6
Figure 2: Itialize interface variables........................................................................................................................7
Figure 3: Initialize the types of seats included in the ticket.........................................................................................7
Figure 4: Initialize foods and drinks.............................................................................................................................8
Figure 5: Set sizes and prices for bread and drink.......................................................................................................8
Figure 6: Install items..................................................................................................................................................9
Figure 7: Install Show Items.........................................................................................................................................9
Figure 8: Initialize orders for customers....................................................................................................................10
Figure 9: Program implementation............................................................................................................................10
Figure 10: Program Result.........................................................................................................................................11
Figure 11: Factory Method class diagram..................................................................................................................15
Figure 12:Prototype Pattern class diagram................................................................................................................16
Figure 13: Builder pattern class diagram...................................................................................................................17
Figure 14: Decorator Pattern class diagram...............................................................................................................18
Figure 15: Flyweight Pattern class diagram...............................................................................................................19
Figure 16: Proxy Pattern class diagram......................................................................................................................20
Figure 17: Mediator Pattern class diagram................................................................................................................21
Figure 18:Iterator Pattern class diagram...................................................................................................................22
Figure 19: State Pattern class diagram......................................................................................................................23
Document Page
I. Introduction
- My team is now separated and perform similar tasks in parallel. I will choose one of the real scenarios that
your team introduced about DP in previous phase, then implement that scenario based on the corresponding
class diagram your team created. I may need to amend the diagram if it is needed for your implementation. In
additional, I should discuss a range of DPs related / similar to your DP, evaluate them against your scenario
and justify your choice.
- In the end, I need to write a report with the following content:
A final version of the class diagram based on chosen scenario which has potential of using DP.
Result of a small program implemented based on the class diagram, explain how you translate from design
diagram to code.
Discussion of a range of DPs related / similar to your DP, evaluate them against your scenario and justify
your choice (why your DP is the most appropriate in that case).
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
II. Implement code applying design patterns.
1. P3 Build an application derived from UML class diagrams.
- As introduced in the Design patterns in the previous task. We have introduced to you 3 types of DP of 23 DP
models.
- Among those 23 DP models, we have introduced to you 3 models representing 3 main groups of DP:
creational, structural and behavioral.
- 3 DP models that my group introduced in the previous task are: Builder (creational group), Flywiegh
(structural group) and Stragery (behavioral group).
- At the request of the mission this time I decided to choose a realistic situation that was to use the
Parttern Builder for ordering food at a fast food restaurant.
- Based on the requirements of the project, I prepared a realistic scenario to introduce the Builder Pattern in the
previous task.
- Scenatio is as follows:
Spiderman
Order at a fast food system
- I received an email from the manager of the south bus terminal company, who heard about your success. He
wants you to create a new OMS for your ticketing system. For the first milestones, he identified a number of
requirements that need to be met by your OMS:
Car ticketing system, Car ticket booking (vip or regular seats) as well as some sandwiches (Big bread,
Small bread) and some drinks (Coca and Pepsi) besides customers Can choose the size they want them to.
The system will be able to represent these products.
All priced products and breads have specific nutrition.
Each bread contains less bread and sauces. It can be selected size of bread supplement (Big, Small), can be
ordered several times.
Breads with certain topping combinations have names, for example: large bread and small bread. Names
should be on the bill. You do not need to automatically detect names for combinations if they are not
explicitly needed in order.
Finally, after finishing the order, the system will display the product information of the customer and the
total amount on the invoice.
- The manager sent you the fastfood menu card to better understand their available items:
Ticket VIP
NORMAL
$250
$150
BREAD BREADBIG
BREADSMALL
$50
$35
DRINK COCA
PEPSI
$50
$35
SIZE BIG
SMALL
$50
$35
Document Page
- Based on the scenario the company manager requested. We have planned to perform that scenario and choose
the most suitable DP to execute that scenario.
- After reaching agreement, we decided to choose the Builder Pattern to design that table script.
- Below is the class diagram that we have defined to implement the above project.
Figure 1: Car ticket Class diagram.
Document Page
2. M3 Develop code that implements a design pattern for a given purpose.
- After we have designed the class diagram according to the builder pattern, we have implemented the script on
c #. Here's how we deploy and execute on c #.
- Itialize interface variables:
Figure 2: Itialize interface variables.
- Initialize the types of seats included in the ticket:
Figure 3: Initialize the types of seats included in the ticket.
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
- Initialize foods and drinks:
Figure 4: Initialize foods and drinks.
- Set sizes and prices for bread and drink
Figure 5: Set sizes and prices for bread and drink.
Document Page
- Install items and display items.
Figure 7: Install Show Items.
Figure 6: Install items
Document Page
- Initialize orders for customers
- Program
implementation
Figure 8: Initialize orders for customers.
Figure 9: Program implementation.
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
- Program Result.
After finishing building the program on C #, the following is the result of the program after running:
Figure 10: Program Result.
Document Page
- Compare Table:
The purpose of using this comparison table is to see how much percent we have completed in the original
scenario and know which parts we have completed and which parts we have not completed. Fort. Thereby
we can perform better tasks better for the following tasks.
#No Scenatio Implement Result
1 Implement vip seats
2 Implement Normal seats
3 Implement Bread
4 Implement Drink coca
chevron_up_icon
1 out of 26
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]