SWE-Week 02
SWE-Week 02
Chapter 14
Pattern-Based Design
© 2020 McGraw Hill. All rights reserved. Authorized only for instructor use in the classroom.
No reproduction or further distribution permitted without the prior written consent of McGraw Hill.
Design Patterns
• Design pattern can be thought of as a three-part rule which
expresses a relation between a certain context, a problem, and a
solution.
• Context allows the reader to understand the environment in
which the problem resides and what solution might be
appropriate within that environment.
© McGraw Hill 2
Effective Design Pattern
• Solves a problem: Patterns capture solutions, not just abstract principles or
strategies.
• Proven concept: Patterns capture solutions with proven track records, not
theories or speculation.
© McGraw Hill 3
Kinds of Patterns 1
"Infrastructure"
• Architectural patterns describe broad-based design problems
that are solved using a structural approach.
© McGraw Hill 4
Kinds of Patterns 2
© McGraw Hill 5
Frameworks
Patterns themselves may not be sufficient to develop a complete
design.
• In some cases it may be necessary to provide an implementation-specific
skeletal infrastructure, called a framework, for design work.
• You can select a reusable architecture that provides the generic structure and
behavior for a family of software abstractions along with their context which
specifies use within a given domain.
© McGraw Hill 6
Pattern Description 1
© McGraw Hill 7
Pattern Description 2
© McGraw Hill 8
Pattern-Based Design
• A software designer begins with a requirements model (either
explicit or implied) that presents an abstract representation of
the system.
• The requirements model describes the problem set, establishes
the context, and identifies the system of forces that hold sway.
• If you discover you are faced with a problem, context, and
system of forces that have solved before then use that solution.
• If it is a new problem then use the methods and modeling tools
available for architectural, component-level, and interface
design to create a new solution (pattern).
© McGraw Hill 9
Pattern-Based Design in Context
© McGraw Hill 10
Thinking in Patterns
1. Be sure you understand big picture (requirements model) - the
context in which the software to be built resides.
2. Examining the big picture, extract the patterns that are present
at that level of abstraction.
3. Begin your design with ‘big picture’ patterns that establish a
context or skeleton for further design work.
4. Work inward from the context, look for patterns at lower levels
of abstraction that contribute to design solution.
5. Repeat steps 1 to 4 until complete design is fleshed out.
6. Refine the design by adapting each pattern to the specifics of
the software you’re trying to build.
© McGraw Hill 11
Design Tasks 1
© McGraw Hill 12
Design Tasks 2
© McGraw Hill 13
Pattern Organizing Table
© McGraw Hill 14
Common Mistakes
• Not enough time has been spent to understand the underlying
problem, its context and forces, and as a consequence, you
select a pattern that looks right, but is inappropriate for the
solution required.
• Once the wrong pattern is selected, you refuse to see your error
and force fit the pattern.
• In other cases, the problem has forces that are not considered
by the pattern you’ve chosen, resulting in a poor or erroneous
fit.
• Sometimes a pattern is applied too literally and the required
adaptations for your problem space are not implemented.
© McGraw Hill 15
Architectural Patterns
Example: every house (and every architectural style for houses)
employs a Kitchen pattern.
Kitchen pattern and patterns it collaborates with address
problems associated with storage and preparation of food, tools
required to accomplish these tasks, and rules for placement of
these tools relative to workflow in the room.
The pattern might address problems associated with counter tops,
lighting, wall switches, a central island, flooring, and so on.
Obviously, there is more than a single design for a kitchen, but
every design can be conceived within the context and system
forces of the ‘solution’ suggested by the Kitchen pattern.
© McGraw Hill 16
Component-Level Design Patterns 1
© McGraw Hill 17
Component-Level Design Patterns 2
© McGraw Hill 18
Search Patterns
• HelpWizard. Users need help on a certain topic related to the
website or when they need to find a specific page within the
site.
• SearchArea. Users must find a page.
• SearchTips. Users need to know how to control the search
engine.
• SearchResults. Users must process a list of search results.
• SearchBox. Users must find an item or specific information.
© McGraw Hill 19
Anti-Patterns
• Anti-patterns describe commonly used solutions to design
problems that usually have negative effects on software quality.
• Anti-patterns can provide tools to help developers recognize
when these problems exist and may provide detailed plans for
reversing the underlying problem causes and implementing
better solutions to these problems.
• Anti-patterns can provide guidance to developers looking for
ways to refactor software to improve its quality.
• Anti-patterns can be used by technical reviewers to uncover
areas of concern.
© McGraw Hill 20
Selected Anti-Patterns
• Blob. Single class with large number of attributes, operators, or both.
• Stovepipe system. A barely maintainable assemblage of ill-related
components.
• Boat anchor. Retaining a part of system that no longer has any use.
• Spaghetti code. Program whose structure is barely comprehensible,
especially because of misuse of code structures.
• Copy and paste programming. Copying existing code several times rather
than creating generic solutions.
• Silver bullet. Assume that a favorite technical solution will always solve a
larger process or problem.
• Programming by permutation. Trying to approach a solution by
successively modifying the code to see if it works.
© McGraw Hill 21
User Interface (UI) Patterns
• Whole UI. Provide design guidance for top-level structure and navigation
throughout the entire interface.
• Top-level Navigation. Provides a top-level menu, often coupled with a logo
or identifying graphic, that enables direct navigation to any of the system’s
major functions.
• Page layout. Address the general organization of pages (for Websites) or
distinct screen displays (for interactive applications).
• E-commerce. Specific to Web sites, these patterns implement recurring
elements of e-commerce applications.
• Shopping cart. Provides a list of items selected for purchase.
© McGraw Hill 22
Mobility Design Patterns
• Check-in screens. How do I check in from a specific location, make a
comment, and share comments with friends and followers on a social
network?
• Maps. How do I display a map within the context of an app that addresses
some other subject?
• Popovers. How do I represent a message or information that arises in real
time or as the consequence of a user action?
• Sign-up flows. How do I provide a simple way to sign in or register for
information or functionality?
• Custom tab navigation. How do I represent a variety of different content
objects in a manner that enables user to select one?
• Invitations. How do I inform the user that he must participate in some
action or dialog?
© McGraw Hill 23
Because learning changes everything. ®
www.mheducation.com
© 2020 McGraw Hill. All rights reserved. Authorized only for instructor use in the classroom.
No reproduction or further distribution permitted without the prior written consent of McGraw Hill.