Unit-3 Oose
Unit-3 Oose
Unit-3 Oose
PART A
1. What is meant by design?
Design is a meaningful engineering representation of something that is to be built.
It can be traced to a customer's requirements and at the same time assessed for quality
against a set of predefined criteria.
5. Mention any eight software design principles. (Apr/May’12) (Or) List the principles of the
software design. Apr/May 2018.
6. Explain the terms: Procedural abstraction, data abstraction and control abstraction.
A "procedural abstraction" is a named sequence of instructions that has a specific and
limited function. Eg: The word "Open the door" implies walk to the door, reach out, grasp
knob, turn knob pull door etc.
A "data abstraction" is a named collection of data that describes a data object. Eg : door.
The word door encompasses a set of attributes like door type, swing direction, opening
mechanism, etc.
Control abstraction implies a program control mechanism without specifying internal
details. Eg : Synchronization semaphore.
8. Describe the properties that should be specified as part of the architectural design.
The properties are: .
Structural properties:
It defines the components of a system and the manner in which those components are
packaged and interact with one another.
Extra functional properties:
The design description should address how the design- architecture achieves requirements
for performance, capacity, reliability, security, adaptability and other system characteristics.
Families of related systems:
The design should include the repeatable patterns commonly encountered in the design. The
design should have the ability to reuse architectural building blocks.
9. List all the five models in which the architectural design can be represented.
The architectural design can be represented using one or more-of a number of different
models namely,
Structural model
Framework model
Dynamic model
Process model
Functional model
Interface design describes how the software communicates within itself, with systems that
inter-operate with it, and with humans who use it.
Component level design transforms structural elements of the software architecture into a
procedural description of software components.
Low-level data design decisions should be deferred until late in the design process.
Refine the first iteration architectural using design heuristics for improved software
quality.
30. What are the three rules that form the basis for the user interface design principles?
The three rules that form the basis for user interface design principles are:
Place the user in control
Reduce the user's memory load
Make the interface consistent
31. How do we design interfaces that allow the user to maintain control?
The following design principles allow the user to maintain control:
Define interaction modes in a way that does not force a user into unnecessary or
undesired actions.
Provide for flexible interaction.
Allow user interaction to be interruptible and undoable.
Streamline interaction as skill levels advance and allow the interaction to be
customized.
Hide technical internals from casual user.
Design for direct interaction with objects that appear on the screen.
33. List the user interface design principles, applicable to all user interface design.
The user interface design principles that are applicable all user interface design are:
User familiarity
Consistency
Minimal surprise
Recoverability
User guidance
User diversity
34. Name the two facilities that allow the users to recover from their mistakes.
The facilities that allow the users to recover from their mistakes are:
Confirmation of destructive actions
The provision of an undo facility
36. What are the necessary factors that decide the presentation of information?
The necessary factors that decide the presentation of information are:
Is the user interested in precise information or in the relationships between different data
values?
How quickly do the information change? Should the change be indicated immediately to the
user?
Should the user take some action in response to a change in information.
Does the user need to interact with the displayed information via a direct manipulation
interface? v. Is the information to be displayed textual or numeric?
37. List any four guidelines for effective use of color in user interfaces.
The four guidelines for effective use of color in user interfaces are:
Limit the number of colors used and be conservative how these are used
Use color change to show a change in system status.
Use color coding in a thoughtful and consistent way.
Be careful about color pairings.
40. Name the documents that must be delivered with the software system.
The documents that must be delivered with the software system are
Functional description document
Installation document
Introductory manual
Reference manual
Administrator's manual
41. What is meant by interface evaluation? List any four usability attributes.
Interface evaluation is the process of assessing the ability of an interface and checking that
meets user requirements. An evaluation is done based on usability attributes.
Some of the usability attributes are
Learn ability
Speed of operation
Robustness
Adaptability
42. How do you apply modularization criteria for monolithic software? (May/Jun’12)
Modular decomposability
Modular composability
Modular understability
Modular continuity
Modular protection
43. What are the design quality attributes “FURPS” meant? (May/Jun’12)
F – functionality
PREPARED BY: Mrs.P.R.JAYANTHI AP/CSE, Ms.G.SARASWATHI AP/CSE, Mrs.K.KAVITHA AP/CSE Page 9
U – Usability
R - Reliability
P - Performance
S – Supportability
44. How is the data warehouse different from a database? How are they similar?
Dissimilarities
S.No Data warehouse Database
1. OLAP OLTP
2. Data analysis and decision making Day to Day operations
3. Update driven Query driven
4. Star and snowflake schema design E-R diagram
5. Structure for corporate view of data Structure to suite departmental view of data
Similarities
Both store data and information
Database is a collection of tables and data warehouse is a collection of data from multiple
sources, stored under a unified schema residing on a single site.
45. If a module has logical cohesion, what kind of coupling is this module likely to have?
May/June 2016.
When a module that performs a tasks that are l0ogically related with each other is called
logically cohesive.
For such module content coupling can be suitable for coupling with other modules.
The content coupling is a kind of coupling when one module makes use of data or control
information maintained in other module.
46. What is the need for architectural mapping using data flow? May/June 2016.
Map the DFD in a program structure amenable to transaction processing.
In this transaction flow, a single data item, called a transaction that triggers other flow along
one of many paths.
It is characterized by data moving along an incoming path that converts external world
information.
47. What architectural styles are preferred for the following systems? Why? Nov/Dec
2016.
(a) Networking
(b) Web based systems
(c) Banking system
48. What UI design patterns are used for the following? Nov/Dec 2016.
a) Page layout
b) Tables
c) Navigation through menus and web pages
d) Shopping cart
What UI design patterns are used for the following? Apr/May 2017, Apr/May 2018
(a)Page layout.
(b)Navigation through menus and web pages.
Define interaction modes in a way that does not force a user into unnecessary or
undesired actions.
Provide for flexible interaction
Allow user interaction to be interruptible and undoable.
Streamline interaction as skill levels advance and allow the interaction to be
customized
Hide technical internals from the casual user.
Design for direct interaction with objects that appear on the screen
Reduce the User’s Memory Load
Reduce demand on short-term memory
Establish meaningful defaults
Define shortcuts that are intuitive
The visual layout of the interface should be based on a real-world metaphor
Disclose information in a progressive fashion
Make the Interface Consistent
Allow the user to put the current task into a meaningful context
Maintain consistency across a family of applications
If past interactive models have created user expectations, do not make changes
unless there is a compelling reason to do so.
UI design patterns for shopping cart
49. List down the steps to be followed for User Interface Design. (April/May 2015) (Or) What
are the golden rules for an interface design. (Nov/Dec 2015)
50. Write a note on FURPS model of design quality. (Nov/Dec 2015) Write a note on FURPS
model. Nov/Dec 2017. Mention the design quality model proposed by Hewlett Packard.
Nov/Dec 2018
The FURPS quality attributes represent a target for all software design:
• Functionality is assessed by evaluating the feature set and capabilities of the program, the
generality of the functions that are delivered, and the security of the overall system.
• Usability is assessed by considering human factors, overall aesthetics, consistency, and
documentation.
• Reliability is evaluated by measuring the frequency and severity of failure, the accuracy of
output results, the mean-time-to-failure (MTTF), the ability to recover from failure, and the
predictability of the program.
• Performance is measured by considering processing speed, response time, resource
consumption, throughput, and efficiency.
• Supportability combines the ability to extend the program (extensibility), adaptability,
serviceability—these three attributes represent a more common term, maintainability—and
in addition, testability, compatibility, configurability the ease with which a system can be
installed, and the ease with which problems can be localized.
52. Draw the context flow graph of a ATM automation system. Nov/Dec 2017
53. Draw the zero level data flow diagram of an ATM system. Nov/Dec 2018
54. How does the Data Flow diagram help in design of software system? April/May 2019
DFD graphically representing the functions, or processes, which capture, manipulate, store,
and distribute data between a system and its environment and between components of a system.
The visual representation makes it a good communication tool between User and System designer.
55. Differentiate internal and external design. (April/May 2021)
Internal Design External design
software.
56. List out the various types of cohesion and coupling. (April/May 2021)
58. Give the GRASP Patterns used for object design. (NOV/DEC 2021)
The following sections present the first five GRASP patterns:
Information Expert
Creator
High Cohesion
Low Coupling
Controller
60. List out some scenarios that illustrate varying degrees of functional cohesion.
Very low cohesion
Low cohesion
High cohesion
Moderate cohesion
68. Define High Cohesion. (NOV / DEC 2012) (NOV / DEC 2021)
High Cohesion is an evaluative pattern that attempts to keep objects appropriately
focused, manageable and understandable. High cohesion is generally used in support of Low
Coupling. High cohesion means that the responsibilities of a given element are strongly related
and highly focused. Breaking programs into classes and subsystems is an example of activities
that increase the cohesive properties of a system.
and principles, the more honed, old and widely used. New patterns should be considered as an
oxymoron (contradiction to original or opposite to real).
84. How to map designs to code? (or) What are the steps for mapping designs to code?
PREPARED BY: Mrs.P.R.JAYANTHI AP/CSE, Ms.G.SARASWATHI AP/CSE, Mrs.K.KAVITHA AP/CSE Page 19
PART - B
1. Explain in detail about Software design.
Software design is an iterative process through which requirements are translated into a
“blueprint” for constructing the software.
Initially, the blueprint depicts a holistic view of software.
That is, the design is represented at a high level of abstraction— a level that can be directly
traced to the specific system objective and more detailed data, functional, and behavioral
requirements.
Software Quality Guidelines and Attributes
Throughout the design process, the quality of the evolving design is assessed with a series of
technical reviews. Mc Glaughlin suggests three characteristics that serve as a guide for the
evaluation of a good design:
• The design must implement all of the explicit requirements contained in the requirements
model, and it must accommodate all of the implicit requirements desired by stakeholders.
• The design must be a readable, understandable guide for those who generate code and for
those who test and subsequently support the software.
• The design should provide a complete picture of the software, addressing the data,
functional, and behavioral domains from an implementation perspective.
Later work proposed methods for the translation of data flow or data structure into a design
definition.
Newer design approaches proposed an object-oriented approach to design derivation. More
recent emphasis in software design has been on software architecture and the design patterns
that can be used to implement software architectures and lower levels of design abstractions.
Growing emphasis on aspect-oriented methods, model-driven development, and test-driven
development emphasize techniques for achieving more effective modularity and
architectural structure in the designs that are created.
All of these methods have a number of common characteristics:
(1) A mechanism for the translation of the requirements model into a design representation,
(2) A notation for representing functional components and their interfaces,
(3) Heuristics for refinement and partitioning, and
(4) Guidelines for quality assessment.
Elements of a system:
Architecture: This is the conceptual model that defines the structure, behavior, and views
of a system. We can use flowcharts to represent and illustrate the architecture. (Refer figure
3.1)
Modules: These are the components that handle one specific task in a system. A
combination of the modules makes up the system.
Components: This provides a particular function or group of related functions. They are
made up of modules.
Interfaces: This is the shared boundary across which the components of a system exchange
information and relate.
Data: This is the management of the information and data flow.
Interface Design:
Interface design is the specification of the interaction between a system and its
environments. This phase proceeds at a high level of abstraction with respect to the inner workings
of the system.
i.e., during interface design, the internal of the systems are completely ignored, and
the system is treated ad black box.
Attention is focused on the dialogue between the target system and the users,
devices, and other systems with which it interacts.
The design problem statement produced during the problem analysis step should
identify the people, other systems, and devices which are collectively called agents.
Interface design should include the following details:
Precise description of events in the environment, or messages from agents to which
the system must respond.
Precise description of the events or messages that the system must produce.
Specification on the data, and the formats of the data coming into and going out of
the system.
Specification of the ordering and timing relationships between incoming events or
messages, and outgoing events or outputs.
Architectural Design:
The architectural design adds important details ignored during the interface design. Design of the
internals of the major components is ignored until the last phase of the design.
Detailed Design:
Design is the specification of the internal elements of all major system components, their
properties, relationships, processing, and often their algorithms and the data structures.
3. Write neatly the basis of Design Concepts. (Or) What is modularity? State its
importance and explain coupling and cohesion. (or) Discuss about the design concepts
in a software development process. (or) List and explain any five fundamental
software design concepts.
A set of fundamental software design concepts has evolved over the history of software
engineering. Although the degree of interest in each concept has varied over the years, each has
stood the test of time. Each provides the software designer with a foundation from which more
sophisticated design methods can be applied.
For example, objects are packaged to encapsulate both data and the processing that
manipulates the data and interact via the invocation of methods.
Extra-functional properties
The architectural design description should address how the design architecture achieves
requirements for performance, capacity, reliability, security, adaptability, and other system
characteristics.
Families of related systems
The architectural design should draw upon repeatable patterns that are commonly
encountered in the design of families of similar systems. In essence, the design should have
the ability to reuse architectural building blocks. Given the specification of these properties,
the architectural design can be represented using one or more of a number of different
models.
Structural models represent architecture as an organized collection of
program components.
Framework models increase the level of design abstraction by attempting to
identify repeatable architectural design frameworks that are encountered in
similar types of applications.
Dynamic models address the behavioral aspects of the program architecture,
indicating how the structure or system configuration may change as a
function of external events.
Process models focus on the design of the business or technical process that
the system must accommodate.
Finally, functional models can be used to represent the functional hierarchy
of a system.
A number of different architectural description languages (ADLs) have been developed to
represent these models.
Patterns
Brad Appleton defines a design pattern in the following manner: “A pattern is a named
nugget of insight which conveys the essence of a proven solution to a recurring problem
within a certain context amidst competing concerns”.
Stated in another way, a design pattern describes a design structure that solves a particular
design problem within a specific context and amid “forces” that may have an impact on the
manner in which the pattern is applied and used.
The intent of each design pattern is to provide a description that enables a designer to
determine
(1) Whether the pattern is applicable to the current work,
(2) Whether the pattern can be reused (hence, saving design time), and
(3) Whether the pattern can serve as a guide for developing a similar, but
functionally or structurally different pattern.
Separation of Concerns
Separation of concerns is a design concept that suggests that any complex problem can be
more easily handled if it is subdivided into pieces that can each be solved and/or optimized
independently.
A concern is a feature or behavior that is specified as part of the requirements model for the
software. By separating concerns into smaller, and therefore more manageable pieces, a
problem takes less effort and time to solve.
Separation of concerns is manifested in other related design concepts:
i) Modularity,
ii) Information hiding,
iii) Functional independence,
iv) Refinement and
v) Aspects.
i) Modularity
Modularity is the most common manifestation of separation of concerns.
Software is divided into separately named and addressable components, sometimes called
modules, which are integrated to satisfy problem requirements.
It has been stated that “modularity is the single attribute of software that allows a program to
be intellectually manageable”.
Monolithic software (i.e., a large program composed of a single module) cannot be easily
grasped by a software engineer. The number of control paths, span of reference, number of
variables, and overall complexity would make understanding close to impossible. In almost
all instances, you should break the design into many modules, hoping to make
understanding easier and, as a consequence, reduce the cost required to build the software.
Referring to Figure 3.2, the effort (cost) to develop an individual software module does
decrease as the total number of modules increases. Given the same set of requirements,
more modules means smaller individual size. However, as the number of modules grows,
the effort (cost) associated with integrating the modules also grow. These characteristics
lead to a total cost or effort curve shown in the figure. There is a number, M, of modules that
would result in minimum development cost, but we do not have the necessary sophistication
to predict M with assurance.
Independent modules are easier to maintain (and test) because secondary effects caused by
design or code modification are limited, error propagation is reduced, and reusable modules
are possible.
To summarize, functional independence is a key to good design, and design is the key to
software quality.
Independence is assessed using two qualitative criteria:
Cohesion
Coupling
Refactoring
An important design activity suggested for many agile methods, refactoring is a
reorganization technique that simplifies the design (or code) of a component without
changing its function or behavior.
Fowler defines refactoring in the following manner: “Refactoring is the process of
changing a software system in such a way that it does not alter the external behavior of
the code [design] yet improves its internal structure.”
When software is refactored, the existing design is examined for redundancy, unused design
elements, inefficient or unnecessary algorithms, poorly constructed or inappropriate data
structures, or any other design failure that can be corrected to yield a better design.
Object-Oriented Design Concepts
The object-oriented (OO) paradigm is widely used in modern software engineering. OO
design concepts such as classes and objects, inheritance, messages, and polymorphism, among
others.
Five different types of design classes, each representing a different layer of the design architecture,
can be developed:
User interface classes define all abstractions that are necessary for human computer
interaction (HCI). In many cases, HCI occurs within the context of a metaphor (e.g., a
checkbook, an order form, a fax machine), and the design classes for the interface may be
visual representations of the elements of the metaphor.
Business domain classes are often refinements of the analysis classes defined earlier. The
classes identify the attributes and services (methods) that are required to implement some
element of the business domain.
Process classes implement lower-level business abstractions required to fully manage the
business domain classes.
Persistent classes represent data stores (e.g., a database) that will persist beyond the
execution of the software.
System classes implement software management and control functions that enable the
system to operate and communicate within its computing environment and with the outside
world.
As the architecture forms, the level of abstraction is reduced as each analysis class is transformed
into a design representation. Design classes present significantly more technical detail as a guide for
implementation.
The four characteristics of a well-formed design class are:
Complete and sufficient. A design class should be the complete encapsulation of all
attributes and methods that can reasonably be expected (based on a knowledgeable
interpretation of the class name) to exist for the class.
Primitiveness. Methods associated with a design class should be focused on accomplishing
one service for the class. Once the service has been implemented with a method, the class
should not provide another way to accomplish the same thing
High cohesion. A cohesive design class has a small, focused set of responsibilities and
single-mindedly applies attributes and methods to implement those responsibilities.
Low coupling. Within the design model, it is necessary for design classes to collaborate
with one another. However, collaboration should be kept to an acceptable minimum. If a
design model is highly coupled (all design classes collaborate with all other design classes),
the system is difficult to implement, to test, and to maintain over time.
Coupling
Coupling is a qualitative measure of the degree to which classes are connected to one
another. As classes (and components) become more interdependent, coupling increases. An
important objective in component-level design is to keep coupling as low as is possible. Class
coupling can manifest itself in a variety of ways. Lethbridge and Laganiére [Let01] define the
following coupling categories:
Content coupling. Occurs when one component “surreptitiously modifies data that is
internal to another component” [Let01]. This violates information hiding—a basic design
concept.
Common coupling. Occurs when a number of components all make use of a global
variable. Although this is sometimes necessary (e.g., for establishing default values that are
applicable throughout an application), common coupling can lead to uncontrolled error
propagation and unforeseen side effects when changes are made.
Control coupling. Occurs when operation A() invokes operation B() and passes a control
flag to B. The control flag then “directs” logical flow within B. The problem with this form
of coupling is that an unrelated change in B can result in the necessity to change the
meaning of the control flag that A passes. If this is overlooked, an error will result.
Stamp coupling. Occurs when ClassB is declared as a type for an argument of an operation
of ClassA. Because ClassB is now a part of the definition of ClassA, modifying the system
becomes more complex.
Data coupling. Occurs when operations pass long strings of data arguments. The
“bandwidth” of communication between classes and components grows and the complexity
of the interface increases. Testing and maintenance are more difficult.
Routine call coupling. Occurs when one operation invokes another. This level of coupling
is common and is often quite necessary. However, it does increase the connectedness of a
system.
Type use coupling. Occurs when component A uses a data type defined in component B
(e.g., this occurs whenever “a class declares an instance variable or a local variable as
having another class for its type” [Let01]). If the type definition changes, every component
that uses the definition must also change.
Inclusion or import coupling. Occurs when component A imports or includes a package or
the content of component B.
External coupling. Occurs when a component communicates or collaborates with
infrastructure components (e.g., operating system functions, database capability,
telecommunication functions). Although this type of coupling is necessary, it should be
limited to a small number of components or classes within a system.
Software must communicate internally and externally. Therefore, coupling is a fact of life.
However, the designer should work to reduce coupling whenever possible and understand the
ramifications of high coupling when it cannot be avoided.
Cohesion
Cohesion as the “single-mindedness” of a component. Within the context of component-level
design for object-oriented systems, cohesion implies that a component or class encapsulates only
attributes and operations that are closely related to one another and to the class or component itself.
Lethbridge and Laganiére define a number of different types of cohesion (listed in order of the level
of the cohesion):
Functional. Exhibited primarily by operations, this level of cohesion occurs when a
component performs a targeted computation and then returns a result.
Layer. Exhibited by packages, components, and classes, this type of cohesion occurs when
a higher layer accesses the services of a lower layer, but lower layers do not access higher
layers. Consider, for example, the SafeHome security function requirement to make an
outgoing phone call if an alarm is sensed. It might be possible to define a set of layered
packages as shown in Figure 3.3. The shaded packages contain infrastructure components.
Access is from the control panel package downward.
Communicational. All operations that access the same data are defined within one class. In
general, such classes focus solely on the data in question, accessing and storing it.
Classes and components that exhibit functional, layer, and communicational cohesion are
relatively easy to implement, test, and maintain. You should strive to achieve these levels of
cohesion whenever possible. It is important to note, however, that pragmatic design and
implementation issues sometimes force you to opt for lower levels of cohesion.
This is actually the concept of having module as functional independence of other modules. There
are advantages of functional independence in software engineering which we are going to discuss
next.
Advantage of functional independence
Advantages of functional independence are given below:
Error isolation
When a module is functionally independent then it performs most of its task
independently without interacting with other modules much. This reduces the chances of
error getting propagated to other modules. This helps in easily isolating and tracing the
error.
Module reusability
A functionally independent module performs some well defined and specific task. So it
becomes easy to reuse such modules in different program requiring same functionality.
Understandability
A functionally independent module is less complex so easy to understand. Since such
modules are less interaction with other modules so can be understood in isolation.
7. Explain about Design patterns in software design.
Definition:
Design patterns represent the best practices used by experienced object-oriented software
developers. Design patterns are solutions to general problems that software developers faced during
software development. These solutions were obtained by trial and error by numerous software
developers over quite a substantial period of time.
What is Gang of Four (GOF)?
In 1994, four authors Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides
published a book titled Design Patterns - Elements of Reusable Object-Oriented
Software which initiated the concept of Design Pattern in Software development.
These authors are collectively known as Gang of Four (GOF). According to these authors
design patterns are primarily based on the following principles of object orientated design.
Program to an interface not an implementation
Favor object composition over inheritance
Usage of Design Pattern
Design Patterns have two main usages in software development.
Common platform for developers
Design patterns provide a standard terminology and are specific to particular scenario.
For example, a singleton design pattern signifies use of single object so all developers
familiar with single design pattern will make use of single object and they can tell each
other that program is following a singleton pattern.
Best Practices
Design patterns have been evolved over a long period of time and they provide best
solutions to certain problems faced during software development. Learning these patterns
helps unexperienced developers to learn software design in an easy and faster way.
1. Creational Patterns:
These design patterns provide a way to create objects while hiding the creation logic,
rather than instantiating objects directly using new operator. This gives program more
flexibility in deciding which objects need to be created for a given use case.
2. Structural Patterns
These design patterns concern class and object composition. Concept of inheritance is
used to compose interfaces and define ways to compose objects to obtain new
functionalities.
3. Behavioral Patterns
These design patterns are specifically concerned with communication between objects.
4. J2EE Patterns
These design patterns are specifically concerned with the presentation tier. These
patterns are identified by Sun Java Center.
The model designs based on the MVC architecture follow MVC design pattern. The
application logic is separated from the user interface while designing the software using
model designs.
o Controller: It works on both the model and view. It is used to manage the flow of
application, i.e. data flow in the model object and to update the view whenever data
is changed.
In the Model/View/Controller (MVC) architectural style (Fig.3.5), subsystems are classified into
three different types: model subsystems maintain domain knowledge, view subsystems display it
to the user, and controller subsystems manage the sequence of interactions with the user.
The model subsystems are developed such that they do not depend on any view or controller
subsystem. Changes in their state are propagated to the view subsystem via a subscribe/notify
protocol. The MVC is a special case of the repository where Model implements the central data
structure and control objects dictate the control flow.
Figure 3.5 - Model/View/Controller architectural style (UML class diagram). The Controller
gathers input from the user and sends messages to the Model. The Model maintains the central data
structure. The Views display the Model and are notified (via a subscribe/notify protocol) whenever
the Model is changed.
For example, Figures 3.6 and 3.7 illustrate the sequence of events that occur in an MVC
architectural style. Figure 6-16 displays two views of a file system. The bottom window lists the
content of the Comp-Based Software Engineering folder, including the file 9DesignPatterns2.ppt.
The top window displays information about this file.
The name of the file 9DesignPatterns2.ppt appears in three places: in both windows and in the
title of the top window. Assume now that we change the name of the file to 9DesignPatterns.ppt.
Figure 3.7 shows the sequence of events:
1. The InfoView and the FolderView both subscribe for changes to the File models they
display (when they are created).
2. The user types the new name of the file.
3. The Controller, the object responsible for interacting with the user during file name
changes, sends a request to the Model.
4. The Model changes the file name and notifies all subscribers of the change.
5. Both InfoView and FolderView are updated, so the user sees a consistent change
Figure 3.6 - An example of MVC architectural style. The “model” is the filename
9DesignPAtterns2.ppt. One “view” is a window titled CBSE, which displays the contents of a
folder containing the file 9DesignPatterns2.ppt. The other “view” is window called
9DesignPatterns2.ppt Info, which displays information related to the file. If the file name is
changed, both views are updated by the “controller.”
9. Write short notes on adapter, singleton, factory, bridges and observer patterns.
(APRIL/MAY 2011) (May-June’13) (May-June’12) (May-June’11)(Nov-Dec’12) (Nov-
Dec’11) (Nov-Dec’13)
DESIGN PATTERN
A pattern is a named description of a problem and solution that can applied to new context,
ideally a pattern advises us on how to apply its solution in varying circumstances and
considers the forces and trade-offs.
Many patterns given a specific category of problem. Guide the assignment of responsibility
to objects.
Name: Adapter
Solution: Convert the original interface of a component into another interface, through
(advice) an intermediate adapter objects.
To review: The NextGen POS system needs to support several kinds of external third-party services,
including tax calculators, credit authorization services, inventory systems, and accounting systems,
among others. Each has a different API, which can't be changed.
A solution is to add a level of indirection with objects that adapt the varying external interfaces to a
consistent interface used within the application refer figure 3.8.
As illustrated in figure 3.9, a particular adapter instance will be instantiated for the chosen external
service, such as SAP for accounting, and will adapt the postSale request to the external interface,
such as a SOAP XML interface over HTTPS for an intranet Web service offered by SAP.
Name: Singleton
Solution: Define a static method of the class that returns the singleton.
The Services Factory raises another new problem in the design: Who creates the factory itself, and
how is it accessed?
First, observe that only one instance of the factory is needed within the process. Second, quick
reflection suggests that the methods of this factory may need to be called from various places in the
code, as different places need access to the adapters for calling on the external services.
Thus, there is a visibility problem: How to get visibility to this single Services Factory instance?
One solution is passing the Services Factory instance around as a parameter to wherever a visibility
need is discovered for it, or to initialize the objects that need visibility to it, with a permanent
reference. This is possible but inconvenient; an alternative is the Singleton pattern.
Occasionally, it is desirable to support global visibility or a single access point to a single instance of
a class rather than some other form of visibility. This is true for the ServicesFactory instance.
Figure 3.11- Implicit getInstance Singleton pattern message in the UML because of the '1' mark.
Another common Singleton implementation question is: Why not make all the service
methods static methods of the class itself, instead of using an instance object with instance-
side methods? For example, what if we add a static method called getAccountingAdapter to
ServicesFactory (refer figure 3.11). But, an instance and instance-side methods are usually
preferred for these reasons:
Instance-side methods permit subclassing and refinement of the singleton class into
subclasses; static methods are not polymorphic (virtual) and don't permit overriding in
subclasses in most languages (Smalltalk excluded).
Most object-oriented remote communication mechanisms (for example, Java's RMI) only
support remote-enabling of instance methods, not static methods. A singleton instance could
be remote-enabled, although that is admittedly rarely done.
A class is not always a singleton in all application contexts. In application X, it may be a
singleton, but it may be a "multi-ton" in application Y.
Related Patterns
The Singleton pattern is often used for Factory objects and Facade objects.
Illustrate and provide an interface for creating families of related or dependent objects without
specifying their concrete classes using factory method. (NOV/DEC 2021)
Factory (GoF)
Name: Factory
Problem: Who should be responsible for creating objects when there are special
considerations, such as complex creation logic, a desire to separate the creation
responsibilities for better cohesion, and so forth?
Solution: Create a Pure Fabrication object called a Factory that handles the creation.
This is also called Simple Factory or Concrete Factory. This pattern is not a GoF design pattern,
but extremely widespread. It is also a simplification of the GoF Abstract Factory pattern and often
described as a variation of Abstract Factory, although that's not strictly accurate.
The adapter raises a new problem in the design: In the prior Adapter pattern solution for external
services with varying interfaces, who creates the adapters? And how to determine which class of
adapter to create, such as TaxMaster-Adapter or GoodAsGoldTaxProAdapter?
If some domain object creates them, the responsibilities of the domain object are going beyond pure
application logic and into other concerns related to connectivity with external software components.
This point underscores another fundamental design principle: Design to maintain a separation of
concerns. That is, modularize or separate distinct concerns into different areas, so that each has a
cohesive purpose. Fundamentally, it is an application of the GRASP High Cohesion principle.
Therefore, choosing a domain object (such as a Register) to create the adapters does not support the
goal of a separation of concerns, and lowers its cohesion.
A common alternative in this case is to apply the Factory pattern, in which a Pure Fabrication
"factory" object is defined to create objects.
Factory objects have several advantages:
Separate the responsibility of complex creation into cohesive helper objects.
Hide potentially complex creation logic.
The pricing strategy (which may also be called a rule, policy, or algorithm) for a sale can vary.
During one period it may be 10% off all sales, later it may be $10 off if the sale total is greater than
$200, and myriad other variations.
How do we design for these varying pricing algorithms?
Since the behavior of pricing varies by the strategy (or algorithm), we create multiple
SalePricingStrategy classes, each with a polymorphic getTotal method (see Figure 3.13).
Each getTotal method takes the Sale object as a parameter, so that the pricing strategy object can
find the pre-discount price from the Sale, and then apply the discounting rule.
The implementation of each getTotal method will be different: PercentDiscountPricingStrategy will
discount by a percentage, and so on.
A strategy object is attached to a context object—the object to which it applies the algorithm. In this
example, the context object is a Sale. When a getTotal message is sent to a Sale, it delegates some of
the work to its strategy object, as illustrated in Figure 3.14.
It is not required that the message to the context object and the strategy object have the same name,
as in this example (for example, getTotal and getTotal), but it is common.
However, it is common—indeed, usually required—that the context object pass a reference to itself
(this) on to the strategy object, so that the strategy has parameter visibility to the context object, for
further collaboration.
Observe that a new factory was used for the strategies; that is, different than the SeruicesFactory.
This supports the goal of High Cohesion—each factory is cohesively focused on creating a related
family of objects.
Bridges
The bridge pattern is a design pattern used in software engineering which is meant to "decouple an
abstraction from its implementation so that the two can vary independently".
The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into
different classes.
When a class varies often, the features of object-oriented programming become very useful because
changes to a program's code can be made easily with minimal prior knowledge about the program.
The bridge pattern is useful when both the class and what it does vary often.
The class itself can be thought of as the implementation and what the class can do as the abstraction.
The bridge pattern can also be thought of as two layers of abstraction.
When there is only one fixed implementation, this pattern is known as the Pimple idiom in the C++
world.
The bridge pattern is often confused with the adapter pattern. In fact, the bridge pattern is often
implemented using the class adapter pattern, e.g. in the Java code below.
Variant: The implementation can be decoupled even more by deferring the presence of the
implementation to the point where the abstraction is utilized.
Implementor (interface)
Defines the interface for implementation classes
Problem: Different kinds of subscriber objects are interested in the state changes or
events of a publisher object, and want to react in their own unique way when
the publisher generates an event. Moreover, the publisher wants to maintain
low coupling to the subscribers. What to do?
Figure 3.18 - Updating the interface when the sale total changes.
When the Sale changes its total, the Sale object sends a message to a window, asking it to refresh its
display.
To review, the Model-View Separation principle discourages such solutions. It states that "model"
objects (non-UI objects such as a Sale) should not know about view or presentation objects such as a
window. It promotes Low Coupling from other layers to the presentation (UI) layer of objects.
A consequence of supporting this low coupling is that it allows the replacement of the view or
presentation layer by a new one, or of particular windows by new windows, without impacting the
non-UI objects.
If model objects do not know about Java Swing objects (for example), then it is possible to unplug a
Swing interface, or unplug a particular window, and plug in something else.
Thus, Model-View Separation supports Protected Variations with respect to a changing user
interface.
To solve this design problem, the Observer pattern (see figure 3.19) can be used.
4. The SaleFrame1 window registers or subscribes to the Sale instance for notification
of "property events," via the addPropertyListener message. That is, when a property (such as total)
changes, the window wants to be notified.
5. Note that the Sale does not know about SaleFrame1 objects; rather, it only knows
about objects that implement the PropertyListener interface. This lowers the coupling of the Sale to
the windowthe coupling is only to an interface, not to a GUI class.
6. The Sale instance is thus a publisher of "property events." When the total changes, it
iterates across all subscribing PropertyListeners, notifying each.
Figure 3.21- The Sale publishes a property event to all its subscribers.
Applying UML: Note the approach to handing polymorphic messages in an interaction diagram in
the figure 3.22, The onPropertyEvent message is polymorphic; the specific cases of polymorphic
implementation will be shown in other diagrams.
No object may be interested in this event, in which case, the Sale has no registered subscribers. But
objects that are interested, "subscribe" or register to interest in an event by asking the publishing to
notify them. This was done with the Sale.addPropertyListener message. When the event happens, the
registered subscribers are notified by a message.
It has been called Observer because the listener or subscriber is observing the event; that term was
popularized in Smalltalk in the early 1980s.
It has also been called the Delegation Event Model (in Java) because the publisher delegates
handling of events to "listeners" is shown in figure 3.23.
For example, a Swing JButton publishes an "action event" when it is pressed. Another object will
register with the button so that when it is pressed, the object is sent a message and can take some
action.
Related Patterns
Observer is based on Polymorphism, and provides Protected Variations in terms of protecting the
publisher from knowing the specific class of object, and number of objects, that it communicates
with when the publisher generates an event.
Figure 3.24 - Applying the Command design pattern to Matches in ARENA (UML class
diagram).
Inheritance and delegation in the Command pattern
The Command design pattern uses specification inheritance between the Command
class and ConcreteCommands, enabling new commands to be added independently
from the Invoker. Delegation is used between ConcreteCommands and Receivers, and
between Invoker and Command, enabling ConcreteCommands to be dynamically
created, executed, and stored.
The Command pattern is often used in a Model/View/Controller software architecture,
where Receivers are model objects, Invoker and Commands are controller objects, and
Clients creating Commands are view objects.
Applying the Command Design Pattern
Although Spectators can watch Matches as they occur, we anticipate that many Matches will
be viewed asynchronously, after the fact.
We apply the Command design pattern and represent each move as a Command object. The
abstract Move object (corresponding to the Command object in the design pattern) provides
the interface to the League and Tournament objects to manipulate Moves independently
from the concrete Games and Matches. The concrete Moves are created by and stored in a
queue in the concrete Match object (Figure 3.25).
To deal with concurrent Spectators replaying the same Match, we need to refine this
solution further. For each request to replay an archived Match, ARENA creates a new
ReplayedMatch that includes its own GameBoard to hold the current state of the replayed
Match and feeds it the Move objects of the archived Match, one at the time. This enables the
same Match to be replayed by many different Spectators independently.
Figure 3.25 - Applying the Command design pattern to Matches and ReplayedMatches
in ARENA (UML class diagram).
Figure 3.26 - Applying the Strategy pattern for encapsulating multiple implementations
of a NetworkInterface (UML class diagram). The LocationManager implementing a
specific policy configures NetworkConnection with a concrete NetworkInterface (i.e., the
mechanism) based on the current location. The Application uses the NetworkConnection
independently of concrete NetworkInterfaces.
An ImageProxy object takes the place of the Image and provides the same interface as the
Image object (Figure 3.28). Simple operations such as width() and height() are handled by
ImageProxy.
When Image needs to be drawn, however, ImageProxy loads the data from disk and creates
a RealImage object. If the client does not invokes the paint() operation, the RealImage
object is not created, thus saving substantial computation time.
The calling classes only access the ImageProxy and the RealImage through the Image
interface.
Figure 3.28 - Delaying expensive computations to transform the object design model using a
Proxy design pattern (UML class diagram).
ProxyObject handles certain requests completely (e.g., determining the size of an image), whereas
others are delegated to the RealObject. After delegation, the RealObject is created and loaded in
memory.
Figure 3.30 - An example of the Facade design pattern (UML class diagram)
Subsystems identified during the initial subsystem decomposition often result from
grouping several functionally related classes. These subsystems are good candidates for
the Facade design pattern and should be encapsulated under one class.
Façade: Encapsulating Subsystems
Name: Facade Design Pattern
Problem description: Reduce coupling between a set of related classes and the rest of the
system.
Solution: A single Facade class implements a high-level interface for a subsystem by
invoking the methods of lower-level classes. A Facade is opaque in the sense that a caller
does not access the lower-level classes directly. The use of Facade patterns recursively
yields a layered system.
14. Write short notes on Architectural styles. What is software architecture? Describe in
detail about different types of software architectures with illustrations. (or) What is
software architecture? Explain the different architectural styles with examples. (or) What
is software architecture? Outline the architectural styles with an example. (or) what are
the different types of architectural styles exist for software and explain any software
architecture in detail . (Apr/May 2021)
PREPARED BY: Mrs.P.R.JAYANTHI AP/CSE, Ms.G.SARASWATHI AP/CSE, Mrs.K.KAVITHA AP/CSE Page 70
Software architecture: At the most simplistic level, you think about the overall shape of
the physical structure. But in reality, architecture is much more. It is the manner in which
the various components of the building are integrated to form a cohesive whole. It is the
way in which the building fits into its environment and meshes with other buildings in its
vicinity.
The software that is built for computer-based systems exhibits one of many architectural
styles. Each style describes a system category that encompasses
(1) a set of components (e.g., a database, computational modules) that perform a
function required by a system;
(2) a set of connectors that enable “communication, coordination and cooperation”
among components;
(3) constraints that define how components can be integrated to form the system;
and
(4) semantic models that enable a designer to understand the overall properties of a
system by analyzing the known properties of its constituent parts.
An architectural style is a transformation that is imposed on the design of an entire system.
The intent is to establish a structure for all components of the system. In the case where an
existing architecture is to be reengineered, the imposition of an architectural style will result
in fundamental changes to the structure of the software including a reassignment of the
functionality of components.
An architectural pattern, like an architectural style, imposes a transformation on the design
of architecture. However, a pattern differs from a style in a number of fundamental ways:
(1) The scope of a pattern is less broad, focusing on one aspect of the architecture
rather than the architecture in its entirety;
(2) A pattern imposes a rule on the architecture, describing how the software will
handle some aspect of its functionality at the infrastructure level (e.g., concurrency);
(3) Architectural patterns tend to address specific behavioral issues within the
context of the architecture (e.g., how real-time applications handle synchronization
or interrupts).
Patterns can be used in conjunction with an architectural style to shape the overall structure
of a system.
15. Give notes on User Interface Design. (Or) Describe the golden rules for interface design.
(Or) Discuss about User Interface Design of Software with an example and neat sketch. (or)
Discuss about User Interface Design of Software with an example and neat sketch.
First, a set of golden rules were identified. These applied to all human interaction with
technology products.
Second, a set of interaction mechanisms were defined to enable software designers to build
systems that properly implemented the golden rules.
These interaction mechanisms, collectively called the graphical user interface (GUI), have
eliminated some of the most egregious problems associated with human interfaces.
The Golden rules
Theo Mandel [Man97] coins three golden rules:
1. Place the user in control.
2. Reduce the user’s memory load.
3. Make the interface consistent.
These golden rules actually form the basis for a set of user interface design principles that guide this
important aspect of software design.
Place the User in Control
Mandel defines a number of design principles that allow the user to maintain control:
Define interaction modes in a way that does not force a user into unnecessary or
undesired actions.
An interaction mode is the current state of the interface. For example, if spell check is selected
in a word-processor menu, the software moves to a spell-checking mode. There is no reason to
force the user to remain in spell-checking mode if the user desires to make a small text edit
along the way. The user should be able to enter and exit the mode with little or no effort.
Provide for flexible interaction.
Because different users have different interaction preferences, choices should be provided. For
example, software might allow a user to interact via keyboard commands, mouse movement, a
digitizer pen, a multitouch screen, or voice recognition commands. But every action is not
amenable to every interaction mechanism. Consider, for example, the difficulty of using
keyboard command (or voice input) to draw a complex shape.
Allow user interaction to be interruptible and undoable.
Even when involved in a sequence of actions, the user should be able to interrupt the sequence
to do something else (without losing the work that had been done). The user should also be
able to “undo” any action.
Streamline interaction as skill levels advance and allow the interaction to be customized.
Users often find that they perform the same sequence of interactions repeatedly. It is
worthwhile to design a “macro” mechanism that enables an advanced user to customize the
interface to facilitate interaction.
Hide technical internals from the casual user.
The user interface should move the user into the virtual world of the application. The user
should not be aware of the operating system, file management functions, or other arcane
computing technology. In essence, the interface should never require that the user interact at a
level that is “inside” the machine (e.g., a user should never be required to type operating
system commands from within application software).
Design for direct interaction with objects that appear on the screen.
The user feels a sense of control when able to manipulate the objects that are
necessary to perform a task in a manner similar to what would occur if the object
were a physical thing. For example, an application interface that allows a user to
“stretch” an object (scale it in size) is an implementation of direct manipulation.
Reduce the User’s Memory Load
Mandel [Man97] defines design principles that enable an interface to reduce the user’s memory
load:
Reduce demand on short-term memory.
When users are involved in complex tasks, the demand on short-term memory can be
significant.
The interface should be designed to reduce the requirement to remember past actions,
inputs, and results. This can be accomplished by providing visual cues that enable a user to
recognize past actions, rather than having to recall them.
Establish meaningful defaults.
The initial set of defaults should make sense for the average user, but a user should be able
to specify individual preferences.
However, a “reset” option should be available, enabling the redefinition of original default
values.
Define shortcuts that are intuitive.
When mnemonics are used to accomplish a system function (e.g., alt-P to invoke the
print function), the mnemonic should be tied to the action in a way that is easy to
remember (e.g., first letter of the task to be invoked).
The visual layout of the interface should be based on a real-world metaphor.
For example, a bill payment system should use a checkbook and check register
metaphor to guide the user through the bill paying process. This enables the user to rely
on well-understood visual cues, rather than memorizing an arcane interaction sequence.
Disclose information in a progressive fashion.
The interface should be organized hierarchically. That is, information about a task, an
object, or some behavior should be presented first at a high level of abstraction. More
detail should be presented after the user indicates interest with a mouse pick.