Top Banner
Impact of Design Pattern on Software Quality Omar Adnan Isaid
34
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Design pattern

Impact of Design Pattern on Software Quality

Omar Adnan Isaid

Page 2: Design pattern

Agenda

• What is Software Quality ?• What is Design Pattern ?• Gang of Four (GoF).• Design Pattern Elements (Explained by Façade

Design Pattern).• Advantages of Design Patterns.• Strategy Design Pattern (Explained by Duck

Game).• Auto Dynamic Difficulty Framework.

Page 3: Design pattern

What is Software Quality ?

• ISO 9126: \Software quality characteristic is a set of attributes of a software product by which its quality is described and evaluated".

• German Industry Standard DIN 55350 Part 11: \Quality comprises all characteristics and significant features of a product or an activity which relate to the satisfying of given requirements".

• ANSI Standard (ANSI/ASQC A3/1978): \Quality is the totality of features and characteristics of a product or a service that bears on its ability to satisfy the given needs".

Page 4: Design pattern

What is Design Pattern?• Design pattern is a solution for a repeatable

problem in the problem design.• A design pattern isn't a finished design that

can be transformed directly into code. • A design pattern is a description or template

for how to solve a problem that can be used in many different situations.

Page 5: Design pattern

Gang Of Four (GoF)

• GoF are Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides

• GoF are documented 23 classic software design patterns in their book : Design Patterns: Elements of Reusable Object-Oriented Software.

• The GoF book first published at October 1994 and documented design patterns already exist but not documented before.

Page 6: Design pattern

Design Pattern Elements

Page 7: Design pattern

Name element

[1] Name: Short ,Comprehensive ,No more than two words.• The meaning of the word Façade in oxford

dictionary "The principal front of building that faces to a street or open space".

• The term Façade strongly related to the goal of the Façade design pattern, which is to provide a unified interface for different subsystems of a system.

Page 8: Design pattern

Design Pattern Problem

[2] Problem• The suitable situation to apply the design

pattern. • The preconditions must be available before

the designer decides to apply certain design pattern.

• the design pattern can clarify the structure of the inflexible designs of certain problems.

Page 9: Design pattern

Façade Design Pattern Problem

• Suitable situation : when a unified interface is needed to decouple different subsystems of a complex system.

• Preconditions before apply Façade Design Pattern1. A simple interface can be applied to access different

subsystems of a system.2. The development of the system will provide tightly coupled

system.3. Each subsystem can have an interface, which can be

accessed using Façade design pattern interface.• Inflexible to apply the Façade design pattern if it will act as a

bottleneck and limit the features of the system.

Page 10: Design pattern

Design Pattern Elements

• [3] Solution • Refers to the description of the problem

solution and the arrangement of the elements.

• The element for the problem’s solution is the class.

Page 11: Design pattern

Design Pattern Solution

Page 12: Design pattern

Façade interface

Page 13: Design pattern

Façade interface can access any subsystems

Page 14: Design pattern

Advantages Of Design Patterns

[A] The Design patterns document the efforts of the experts , who did their best efforts to provide flexible and reusable software.[B] The Design Pattern concerns with a flexible software architecture.The points [A] & [B] implies a set of advantages for the developers, designers and others.

Page 15: Design pattern

Advantages Of Design Patterns• The Design Patterns provide a set of

advantages for the developers and designers1. Not to reinvent the wheel.2. Trade off between different solutions for the

same problem(Get the right pattern faster).3. Studying the design patterns improves the

experience and knowledge of novices.

Page 16: Design pattern

Strategy Design Pattern

• Assume the scenario where a certain game has different types of ducks.

• The ducks in the game are different in their sound and behavior.

• Not all the ducks have the same way of flying or have the same sound.

Page 17: Design pattern

Duck Hunt! NES 1984

Page 18: Design pattern

Inheritance Solution

Page 19: Design pattern

Override subclass methods

Page 20: Design pattern

Disadvantages of Duck Inheritance

• If the Duck superclass has a lot of subclasses serious disadvantages can be emerged

• For example, if the Duck superclass has 50 subclasses , where each Duck has a different voice and behavior .

• The developer must override 100 methods making some bugs in the road.

• At least some methods for different subclasses may be modified from time to time.

Page 21: Design pattern

Interface Design

Page 22: Design pattern

Problems of Interface Design

• The interface design eliminates the overhead of override the frequently changed methods of the superclass Duck.

• If the mallard and red head ducks have the same fly and sound behaviors , then the code of fly and sound methods for the MallardDuck and RedheadDuck classes are duplicated.

• The inheritance design means to modify methods from time to time .But, interface design causes code duplication , which is maintenance problem!

• No code reuse

Page 23: Design pattern

The Strategy Design Pattern Solution

Take the parts that vary and encapsulate them so that later you

can alter or extend the parts that vary without affecting those that

do not

Page 24: Design pattern

Interchangeable algorithms

• The Duck behavior (sound or fly) can be described as set of interchangeable algorithm.

• For example the algorithms for the sound behavior can be quack , squeak or mute

• The algorithms are interchangeable because the Duck sound can one of them.

Page 25: Design pattern

Strategy Design Pattern

Page 26: Design pattern

Implementing Fly and Sound Algorithms

Page 27: Design pattern

Advantages of the Strategy Design

• Reusability : Objects can use fly , quack behaviors because these behaviors are not hided anymore in the Duck superclass

• Maintainability : Modify existing behaviors without make any modifications on the subclasses of the Duck superclass

Page 28: Design pattern

Medal of Strategy Pattern

Page 29: Design pattern

Pattern Coupling (McNatt et. al,2011)

• The system architecture can be viewed as a set of design patterns connected together.

• The coupled design patterns is a pair of design patterns connected together using common classes.

Page 30: Design pattern

Types of Coupling

1. Tight Coupling 2. Loose Coupling

Page 31: Design pattern

Tight Coupling

• The common classes strongly connected the design pattern couple.

• Tight coupling leads to a large block of code.• Any modification in the design pattern couple

can have a serious cost.

Page 32: Design pattern

Loosely Coupling

• The common classes loosely connect the design pattern couple.

• This type results in a maintainable and reusable design pattern couple.

Page 33: Design pattern

Overlapping Of Abstract Factory and Visitor Patterns

Page 34: Design pattern

Auto Dynamic Difficulty Framework

• The ADD is framework to change the game experience to match the player experience.

• The reusing of the ADD design patterns eliminates the waste of cost and time to create the ADD game-by-game