Sadp Lab Manual PDF
Sadp Lab Manual PDF
Sadp Lab Manual PDF
LABORATORY MANUAL
IV B.Tech. – I Semester
ESTABLISHED BY
SRI VISHNU EDUCATIONAL SOCIETY
153, SITA NILAYAM, DWARAKAPURI COLONY, PUNJAGUTTA
HYDERABAD-500082
VISHNU INSTITUTE OF TECHNOLOGY
VISION
To ignite the minds of the students through academic excellence so as to bring about social
transformation and prosperity.
MISSION
To expand the frontiers of knowledge through Quality Education.
To provide value added Research and Development.
To embody a spirit of excellence in Teaching, Creativity, Scholarship and Outreach.
To provide a platform for synergy of Academy, Industry and Community.
To inculcate high standards of Ethical and Professional Behavior.
VISION
To build a strong teaching-learning base with a flair for innovation and research that responds to
the dynamic needs of the software industry and the society.
MISSION
To provide strong foundation both in theory and applications of Computer Science &
Engineering, so as to solve real-world problems
To empower students with state-of-art knowledge and up to date technological skills,
making them globally competent
To promote research, innovation and entrepreneurship with focus on industry and social
outreach
To foster civic minded leadership with ethics and values among students
i
COURSE STRUCTURE
IV Year - I Semester
ii
PROGRAM EDUCATIONAL OBJECTIVES
Graduates will have knowledge of mathematics, science, engineering fundamentals, and
in-depth studies in Computer Science Engineering, and will be able to apply them for
formulating, analyzing and solving real world problems.
Graduates will succeed in earning coveted entry level positions in leading Computer
Software and Hardware Firms in India and abroad.
Graduates will succeed in the pursuit of advanced degrees and research in engineering or
other fields and will have skills for continued, independent, lifelong learning and
professional development throughout life.
Graduates will have good communication skills, leadership qualities, ethical values and
will be able to work in teams with due attention to their social responsibilities.
PROGRAM OUTCOMES
An ability to apply knowledge of computing, mathematics, science and engineering
fundamentals to the solution of complex engineering problems.
An ability to formulate and analyze a problem, and define the computing requirements
appropriate to its solution using basic principles of mathematics, science and computer
engineering.
An ability to design, implement, and evaluate a computer based system, process,
component, or software to meet the desired needs.
An ability to design and conduct research based experiments, perform analysis and
interpretation of data and provide valid conclusions.
An ability to use current techniques, skills, and tools necessary for computing practice.
An understanding of legal, health, security, cultural and social issues, and thereby ones
responsibility in their application in Professional Engineering practice.
An understanding of the impact of professional engineering solutions on environmental
context and the need for sustainable development.
An understanding and commitment towards the professional and ethical responsibilities
of an engineer.
An ability to function effectively as an individual, and as a team member/leader in
accomplishing a common goal.
An ability to communicate effectively, make effective presentations and write and
comprehend technical reports and publications.
An ability to learn and adopt new technologies, and use them effectively towards
continued professional development throughout the life.
An understanding of engineering and management principles and their application to
manage projects in the software industry.
iii
Regd.No: ____________________________________
SUMMARY OF WORK-DONE
Marks
Exercise
Date Lab Record Signature
No. Viva Total(15)
(5) (5)
1
10
11
12
13
14
15
iv
SOFTWARE ARCHITECTURE AND DESIGN PATTERNS LAB
Course Objectives:
Construct UML diagrams for static view and dynamic view of the system.
Generate creational patterns by applicable patterns for given context.
Create refined model for given Scenario using structural patterns.
Construct behavioral patterns for given applications.
Course Outcomes:
At the end of this lab session, the student will
patterns
Learning Resources
Text Books
Grady Booch , James Rumbaugh , Ivar Jacobson : The Unified Modeling
Language User Guide, Pearson Education
Design Patterns By Erich Gamma, Pearson Education
Meta Patterns designed by Wolf gang , Pearson.
References
1. Design Patterns Explained By Alan Shalloway, Pearson Education..
2. Head First Design Patterns By Eric Freeman - Oreilly-spd.
3. JAVA Enterprise Design Patterns Vol-III By Mark Grand , Wiley Dreamtech.
4. Pattern‟s in JAVA Vol-I By Mark Grand ,Wiley Dreamtech.
4. Pattern‟s in JAVA Vol-II By Mark Grand ,Wiley Dreamtech.
v
SOFTWARE ARCHITECTURE AND DESIGN PATTERNS LAB
SYLLABUS
Software Architecture Lab
The course project is divided in 6 small components that will be
performed during the different lab sessions; there are, in principle, 7 lab
sessions. The project consists of the design and implementation of the software
architecture of a Weather Mapping System (WMS). Implementation will take
place both in Java and C++ (combination of both languages). Each lab
assignment consists of a theoretical part and a practical part, which are
defined in specific lab assignment statements that are posted at least one or
two weeks before the session. Report and demo (if applicable) for each
assignment is due for the following session.
Report and demo (if applicable) for each assignment is due for the following
session.
1. Tool Presentation
IDL document generation; Java code generation from a UML model etc.
vi
Lab Reports:
Lab reports should include:
• The answers to the questions included in the assignment statement. The
answers should motivate briefly your design choices.
• The printout of the diagrams and related documents (e.g. class, use cases,
operations descriptions etc.) produced using Rational Rose.
Reference: http://www.ece.uvic.ca/~itraore/seng422-06/eng422-06.html
Design Patterns Lab
S. No Programs
1. Use case Diagram for Librarian Scenario
2. Using UML design Abstract factory design pattern
3. Using UML design Adapter-class Design pattern
4. Using UML design Adapter-object Design pattern
5. Using UML design Strategy Design pattern
6. Using UML design Builder Design pattern
7. Using UML design Bridge Design pattern
8. Using UML design Decorator Design pattern
9. User gives a print command from a word document. Design to
represent
this chain of responsibility Design pattern
10. Design a Flyweight Design pattern
11. Using UML design Facade Design pattern.
12. Using UML design Iterator Design pattern
13. Using UML design Mediator Design pattern
14. Using UML design Proxy Design pattern
15. Using UML design Visitor Design pattern
vii
Software Architecture and Design Patterns Lab 2019-2020
Introduction to UML
What is UML?
"The Unified Modeling Language (UML) is a language for specifying, visualizing,
constructing, and documenting the artifacts of software systems, as well as for business
modeling and other non software systems".— OMG UML Specification
"UML is a graphical notation for modeling various aspects of software systems."
Why use UML?
Two questions, really:
1) Why use a graphical notation of any sort?
Facilitates construction of models that in turn can be used to:
Reason about system behavior.
Present proposed designs to others.
Document key elements of design for future understanding.
2) Which graphical notation should be used?
UML has become the de-facto standard for modeling object oriented systems.
UML is extensible and method-independent.
UML is not perfect, but it's good enough.
UML Diagram Types
There are several types of UML diagrams:
Use-case Diagram
Shows actors, use-cases, and the relationships between them.
Class Diagram
Shows relationships between classes and pertinent information about classes
themselves.
Object Diagram
Shows a configuration of objects at an instant in time.
Interaction Diagrams
Show an interaction between a group of collaborating objects.
Two types: Collaboration diagram and sequence diagram
Package Diagram
Shows system structure at the library/package level.
State Diagram
Describes behavior of instances of a class in terms of states, stimuli, and transitions.
Activity Diagram
Very similar to a flowchart—shows actions and decision points, but with the ability to
accommodate
concurrency.
Deployment Diagram
Shows configuration of hardware and software in a distributed system.
So learning notations should be emphasized from the very beginning. Different notations
are available for things and relationships. And the UML diagrams are made using the
PART-1
Software Architecture Lab
The course project is divided in 6 small components that will be performed
during the different lab sessions; there are, in principle, 7 lab sessions. The project
consists of the design and implementation of the software architecture of a Weather
Mapping System (WMS). Implementation will take place both in Java and C++
(combination of both languages). Each lab assignment consists of a theoretical part and
a practical part, which are defined in specific lab assignment statements that are posted
at least one or two weeks before the session. Report and demo (if applicable) for each
assignment is due for the following session.
Report and demo (if applicable) for each assignment is due for the following session.
1. Tool Presentation
This session is an introductory session; there is no lab assignment for this
session. Introduction to working with an industrial strength software development
environment, namely Rational Rose: how to write and maintain a UML specification;
configuration management; architecture design; CORBA-IDL document generation; Java
code generation from a UML model etc.
Theory:
• Software design and implementation is the stage in the software engineering
process at which an executable software system is developed.
• Software design and implementation activities are invariably inter-leaved.
• They require a lot of effort for development and maintenance of these models
and, for small systems, this may not be cost-effective.
Architectural design
Once interactions between the system and its environment have been understood,
you use this information for designing the system architecture.
You identify the major components that make up the system and their
interactions, and then may organize the components using an architectural
pattern such as a layered or client-server model.
The weather station is composed of independent subsystems that communicate by
broadcasting messages on a common infrastructure.
When a command is issued to transmit the weather data, the weather station
processes and summarizes the collected data. The summarized data is transmitted
to the mapping computer when a request is received.
Weather station object classes
• Object class identification in the weather station system may
be based on the tangible hardware and data in
the system:
– Ground thermometer, Anemometer, Barometer
• Application domain objects that are ‘hardware’ objects related to
the instruments in the system.
– Weather station
Design models
• Design models show the objects and object classes and relationships between
these entities.
• Static models describe the static structure of the system in terms of object
classes and relationships.
• Dynamic models describe the dynamic interactions between
objects
Examples of design models
• Subsystem models that show logical groupings of objects into coherent
subsystems.
• Sequence models that show the sequence of object interactions.
• State machine models that show how individual objects change their
state in response to events.
• Other models include use-case models, aggregation models, generalisation
models, etc.
Subsystem models
• Shows how the design is organised into logically related groups of
objects.
• In the UML, these are shown using packages - an encapsulation construct. This is
a logical model. The actual organisation of objects in the system may be different
Sequence models
• Sequence models show the sequence of object interactions that take
place
o Objects are arranged horizontally across the top;
o Time is represented vertically so models are read top to bottom;
o Interactions are represented by labelled arrows, Different styles of arrow
represent different types of interaction;
o A thin rectangle in an object lifeline represents the time when the object is
the controlling object in the system.
Sequence diagram describing data Collection
State diagrams
State diagrams are used to show how objects
respond to different service requests and the state transitions triggered
by these requests.
State diagrams are useful high-level models of a system or an object’s
run-time behavior.
You don’t usually need a state diagram for all of the objects in the
system. Many of the objects in a system are relatively simple and a
state model adds unnecessary detail to the design.
Interface specification
• Object interfaces have to be specified so that the objects and other components
can be designed in parallel.
• Designers should avoid designing the interface representation but should hide this
in the object itself.
• Objects may have several interfaces which are viewpoints on the methods
provided.
• The UML uses class diagrams for interface specification but Java may also be
used.
• Weather station interfaces
PART-II
DESIGN PATTERN INTRODUCTION
UML class diagram example for the Abstract Factory Design Pattern.
Intent
The figure below shows a UML class diagram for the Adapter Pattern:
The answer is simple. You get an adapter which you can put into the power
socket and then you put your plug into the other end of the adapter. The
adapter changes the form of your plug so that you can use it with the power
socket. In that example and in most other situations, the adapter doesn’t
provide any additional functionality. It just enables you to connect your plug to
the power socket.
The adapter class implements the expected interface and keeps a reference to
an object of the class you want to reuse. The methods defined by the interface
call one or more methods on the referenced object and return a value of the
expected type. By doing that, the adapter class fulfills the expected contract by
implementing the interface and enables you to reuse existing, incompatible
implementation.
Implementation
The context object receives requests from the client and delegates them to the
strategy object. Usually the ConcreteStartegy is created by the client and passed to
the context. From this point the clients interacts only with the context.
The more complex an application is the complexity of classes and objects used
increases. Complex objects are made of parts produced by other objects that need
special care when being built. An application might need a mechanism for building
complex objects that is independent from the ones that make up the object. If this is
the problem you are being confronted with, you might want to try using the Builder
(or Adaptive Builder) design pattern.
This pattern allows a client object to construct a complex object by specifying only its
type and content, being shielded from the details related to the objects
representation. This way the construction process can be used to create different
representations. The logic of this process is isolated from the actual steps used in
creating the complex object, so the process can be used again to create a different
object form the same set of simple objects as the first one.
Intent
1. Defines an instance for creating an object but letting subclasses decide which
class to instantiate
2. Refers to the newly created object through a common interface.
The Builder design pattern uses the Factory Builder pattern to decide which concrete
class to initiate in order to build the desired type of object, as we will see below in the
UML diagram:
The Builder class specifies an abstract interface for creating parts of a Product
object.
The Concrete Builder constructs and puts together parts of the product by
implementing the Builder interface. It defines and keeps track of the
representation it creates and provides an interface for saving the product.
The Director class constructs the complex object using the Builder interface.
The Product represents the complex object that is being built.
The figure below shows a UML class diagram for the Bridge Pattern:
We are demonstrating use of Decorator pattern via following example in which we'll
decorate a shape with some color without alter shape class.
Intent
Attach additional responsibilities to an object dynamically. Decorators provide
a flexible alternative to sub classing for extending functionality.
Also Known As
Wrapper
Applicability
Use Decorator
1. To add responsibilities to individual objects dynamically and transparently,
that is, without affecting other objects.
2. for responsibilities that can be withdrawn.
3. when extension by sub classing is impractical. Sometimes a large number of
independent extensions are possible and would produce an explosion of
subclasses to support every combination. Or a class definition may be hidden
or otherwise unavailable for sub classing.
Implementation
We're going to create a Shape interface and concrete classes implementing the
Shape interface.We then create a abstract decorator class ShapeDecorator
implementing the Shape interface and havingShape object as its instance variable.
RedShapeDecorator is concrete class implementing ShapeDecorator.
Class Diagram
Flyweight - Declares an interface through which flyweights can receive and act on
extrinsic state.
Concrete Flyweight - Implements the Flyweight interface and stores intrinsic state.
A Concrete Flyweight object must be sharable. The Concrete flyweight object must
maintain state that it is intrinsic to it, and must be able to manipulate state that is
extrinsic. In the war game example graphical representation is an intrinsic state,
where location and health states are extrinsic. Soldier moves, the motion behavior
manipulates the external state (location) to create a new location.
Flyweight Factory - The factory creates and manages flyweight objects. In addition
the factory ensures sharing of the flyweight objects. The factory maintains a pool of
different flyweight objects and returns an object from the pool if it is already created,
adds one to the pool and returns it in case it is new.
In the war example a Soldier Flyweight factory can create two types of flyweights : a
Soldier flyweight, as well as a Colonel Flyweight. When the Client asks the Factory for
a soldier, the factory checks to see if there is a soldier in the pool, if there is, it is
returned to the client, if there is no soldier in pool, a soldier is created, added to pool,
30 Dept. Of CSE Vishnu Institute Of Technology
Software Architecture and Design Patterns Lab 2019-2020
and returned to the client, the next time a client asks for a soldier, the soldier created
previously is returned, no new soldier is created.
Client - A client maintains references to flyweights in addition to computing and
maintaining extrinsic state
A client needs a flyweight object; it calls the factory to get the flyweight object. The
factory checks a pool of flyweights to determine if a flyweight object of the requested
type is in the pool, if there is, the reference to that object is returned. If there is no
object of the required type, the factory creates a flyweight of the requested type, adds
it to the pool, and returns a reference to the flyweight. The flyweight maintains
intrinsic state (state that is shared among the large number of objects that we have
created the flyweight for) and provides methods to manipulate external state (State
that vary from object to object and is not common among the objects we have created
the flyweight for).
Class Diagram: