Object-Oriented Software Development: Design Patterns Report Analysis

Verified

Added on  2022/08/21

|5
|1267
|11
Report
AI Summary
This report delves into the application of design patterns in object-oriented software development, focusing on the MITS4002 course. The analysis covers several design patterns, including Abstract Factory, Builder, Factory Method, Prototype, and Singleton, explaining their use cases and benefits. The report then applies these patterns to two specific design problems: computing price and checkout processes. For the compute price case, the Template Method pattern is identified as the most suitable, with an explanation of its implementation and advantages like code reuse and algorithm flexibility. The Chain of Responsibility pattern is recommended for the checkout use case, emphasizing its ability to manage dynamic gift offers and price modifications. The report also discusses security design patterns like Authoritative Source of Data, completeness, and reusability, highlighting their roles in ensuring data integrity and system security. Modified class diagrams are included to illustrate the practical application of these patterns, and references provide context and further reading.
Document Page
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
Introduction
A design pattern expresses a solution in terms of interfaces and objects. It has four elements including
the name of the pattern which is a handle used to give a description of a problem, the solution to the
problem and the consequences. The problem describes the pattern to be applied to realize the solution.
The third element of a design patter in the solution which describes the design making elements,
relationships between different elements of the design and their collaborations and responsibilities. The
final element of a design patter is the consequences element which describes the trade-offs and results
of using the pattern.
Designing object-oriented programs requires the designer to consider many factors like reusability by
designing the program using objects factored into granular classes. This design pattern helps the
program to address future problems that may arise as a result of maintenance of the program by
avoiding complete redesigning of the software. Use of design patterns in development of software
makes it easy to reuse the designs.
Question 1
To accomplish productivity while developing software, the following patterns can be applied [2];
Abstract factor– This is also known as Kit. It provides an interface used to create groups of
objects that are related without specification of their concrete class. Abstract factory helps
increase productivity of a software development. For example, a user interface toolkit
supporting multiple look and feels can be use this design pattern through the definition of an
abstract widget factory class declaring an interface used to create the basic kind of widget. Thus,
abstract factory is best used when:
o The system needs independence from how the products making it are composed,
represented and created.
o A system required configuration with one product from a family of multiple products
o A family of objects that are related having products enforcing the same constraint and
their design allows them to be used together.
o When there is need to for a class library composed of products that need their
interfaces revealed while at the same time not revealing their implementations.
Builder – This pattern separates complex object construction from its representation to make it
possible for the same construction process to be used to create other representations that are
different. Scenarios to use the builder pattern include;
o The algorithm to be used to create a complex object is independent of the parts making
up the object and their assembly process.
o Need for the object being constructed to allow different representations.
Factory method (Virtual constructor)– This pattern defines an interface that is used to created
an object while letting the subclasses decide which class should be instantiated. This method
allows the instantiation of a class to defer from its subclasses. This pattern is best used when
o A class doesn’t know the class of objects it’s supposed to create
o A class wanting objects to be created to be specified by its subclasses.
Document Page
o A class gives responsibility to one of its subclasses that is helper and there is need to
localize the knowledge of the helper class that is the delegate.
Prototype– This pattern specifies the kind of objects it should create using an instance that is a
prototype, and create new objects copied from the prototype. This pattern is best used when;
o The classes needed to be instantiated have to be specified during run-time
o There is need to avoid building a hierarchical class of factories that are parallel to the
hierarchical class of products.
o Class instances can have only one of a few different state combinations.
Singleton– This pattern ensures a class has only one individual instance and provides a point of
access to it that is global. A singleton is best used when;
o There must be only one instance of a class that should be accessible to clients from an
access point that is well known.
o An individual instance should be extensible using subclasses and should have the ability
to use an instance that is modified without modification of its code.
2
Compute price (Design problem 1)
a. The best pattern to use as the candidate design is template method. Template method is the
best to use for the compute price case study because there is need to compute price for
different shipping and handling fees for different locations as per the price policy, template
method is the most applicable pattern because it helps implement the parts of an algorithm that
are invariant only once leaving the subclasses to implement the behavior that can vary thus the
algorithm will remain the same but the calculation of the price will be based on the algorithm
b. Modified class diagram
c. Importance of incorporating the template method;
Template method is suitable for use in the design of the computing price use case because it
encourages code reuse as it acts as a means through which behavior can be factored in library
classes. Since price computing depends on different factors like locations the algorithm for the
calculation can be implemented and then used for calculation of different price policies.
Document Page
d. The selected security design patterns are;
I. Authoritative source of data;
i. Level of abstraction – The pattern can be easily reusable because data is always
authorized.
ii. Completeness – This pattern is complete for the compute price use case
because there are varying price policies;
iii. Reusability - The pattern can be easily reusable because data is always
authorized.
iv. Pattern of composability – This pattern is related to session and layered security
patterns
v. Security composability – This pattern is related to session and layered security
sessions
vi. Valid-ability – This pattern because it maintains data integrity.
Design problem 2 (Checkout)
a. The best pattern to use is the chain of responsibility pattern because chain of responsibility
avoids coupling the request sender to its receiver by giving many objects a chance to handle the
request thus when offering and withdrawing various gifts dynamically, the prices can easily be
modified
b. Modified class diagram
c. Importance of incorporating the chain responsibility pattern;
Chain of responsibility is the most suitable for the checkout use case because it uses classes to
represent rules of grammar thus inheritance can be used to change the grammar thus
modification of the price ranges of free gifts will be easy
d. The selected security design patterns are;
I. Authoritative source of data;
i. Level of abstraction – The pattern can be easily reusable because data is always
authorized [1].
ii. Completeness – This pattern is complete for the compute price use case
because there are varying price policies;
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
iii. Reusability - The pattern can be easily reusable because data is always
authorized.
iv. Pattern of composability – This pattern is related to session and layered security
patterns
v. Security composability – This pattern is related to session and layered security
sessions
vi. Valid-ability – This pattern because it maintains data integrity.
References
[1]G. Peipman, "Design Patterns: Elements of Reusable Object-Oriented Software", Gunnar Peipman.
[Online]. Available: https://gunnarpeipman.com/design-patterns/. [Accessed: 23- Jan- 2020].
[2]S. Romansky, "Security Design Patterns", 2011. [Online]. Available:
https://resources.sei.cmu.edu/library/asset-view.cfm?assetid=9115. [Accessed: 23- Jan- 2020].
chevron_up_icon
1 out of 5
circle_padding
hide_on_mobile
zoom_out_icon
logo.png

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]