0% found this document useful (0 votes)
53 views40 pages

SDA Lab

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 40

NATIONAL UNIVERSITY OF COMPUTER AND EMERGING

SCIENCES

Software Design and Architecture (SE220)


Lab Instructor: Noureen Fatima

Component Diagram:
While other UML diagrams, which describe the functionality of a system, componentdiagrams are used
to model the components that help make those functionalities.
Component diagrams: are used to visualize the organization of system components and the dependency
relationships between them. They provide a high-level view of the components within a system. The
components can be a software component such as a database or user interface; or a hardware component
such as a circuit, microchip or device; or a business unit such as supplier, payroll or shipping.
Component diagrams.
 Are used in Component-Based-Development to describe systems with Service-Oriented
Architecture
 Show the structure of the code itself
 Can be used to focus on the relationship between components while hidingspecification
detail
 Help communicate and explain the functions of the system being built to
stakeholders

Component Diagram Symbols


Example 02
This diagram demonstrates a number of components and their inter-relationships. Assembly connectors
connect the provided interfaces supplied by Product and Customer to the required interfaces specified
by Order. A Dependency relationship maps a customer's associated account details to the required
interface Payment, also specified by Order.
Deployment Diagram :

Deployment diagrams are parts of the Physical view. This view is concerned with the physical
elements of your system, such as executable software files and the hardware they run on.
Deployment diagrams bring the software into real world by showing how software gets assigned
to hardware and how the pieces communicate.
Component

Example:
Class work:

The iTunes setup can be downloaded from the iTunes website, and also it can be installed on the
home computer. Once the installation and the registration are done, iTunes application can easily
interconnect with the Apple iTunes store. Users can purchase and download music, video,TV
serials, etc. and cache it in the media library.
Devices like Apple iPod Touch and Apple iPhone can update its own media library from the
computer with iTunes with the help of USB or simply by downloading media directly from the
Apple iTunes store using wireless protocols, for example;Wi-Fi, 3G, or EDGE.
Task 1:
Three entity classes are used in a collaboration – CarSharer, Journey and Address. Each of these
classes will be implemented by a (.java) source file. These classes are used across a number of use
cases and are grouped together into a CarSharing component as Java (.class) files. here we are just
dealing with the source files. There are two other classes MCSUserInterface and MCSControl.
Each of these will be implemented by a (.java) file. The MCSControl component has a dependency
on the CarSharing component and on the MCSUserInterface component
Draw a component diagram showing the source code dependencies. The .class files are grouped
together into two Java archive (.jar) files. The MCSControl.class component will need to read a
configuration file (MCS.ini) and display a help file (MCS.hlp) when required. The MCSControl
(.class) file also has dependencies on the MCSUserInterface (.java) file and the CarSharing (.jar)
components.
Task 2:
Draw a deployment diagram given that the nodes are three client PCs, a server and a printer. The
communications protocol between the clients and server is TCP/IP; and between the server and
the printer is a standard parallel printer protocol. The user interface and the control objects will
run on the clients.
Task 3:
Create a component diagram:
An online examination system is a computer-based test system that may be used to conduct
computer-based tests online. This test system doesn't use as many resources and doesn't need
question papers or answer scripts. It also doesn't need to schedule exam rooms, coordinate
invigilators, or do other things. This online examination system gives the examination procedure
more flexibility and security. Once all of the questions have been submitted, the system can shuffle
and assign questions to students in different orders. This reduces the possibility of cheating. The
purpose of the online examination approach is to evaluate students' knowledge of the subject. In
comparison to traditional pen-and-paper testing, this method minimizes logistical problems and
disadvantages. Students are not required to gather in the classroom for the exam.
Task 4:
Need to be uploaded
Assa NATIONAL UNIVERSITY OF COMPUTER AND
EMERGING SCIENCES
SL-2002 – Software Design & Architecture Lab
Lab Instructor: Syeda Rubab Manzar
[email protected]

Lab 11

Outline
• State chart or state machine diagram
• Exercise

Objectives: To Understand State Chart/State Machine Diagram


We want to create a machine having two states, S1 and S2 where S1 is initial state. Then event E1 is created to
do a transition from S1 to S2. In papyrus a machine would then look like something shown below.

A state is denoted by a round-cornered rectangle with the name of the state written inside it.
Choice Pseudo-State Example

Define Entry/Exit
Junction Pseudo-State

History States

Concurrent Regions
Example:
1. There is a control button available for the user of the oven. If the oven is idle with the door is closed and
you push the button, the oven will start cooking (that is, energize the power-tube for one minute).
2. Also while cooking, another button is pushed, it will cause the oven to cook for extended time.
3. Pushing the button when the door is open has no effect (because it is disabled).
4. Whenever the oven is cooking or the door is open the light in the oven will be on.
5. Opening the door stops the cooking.
6. Closing the door turns off the light. This is the normal idle state, prior to cooking when the user has placed
food in the oven.
7. If the oven times-out the light and the power-tube are turned off and then a beeper emits a sound to
indicate that the cooking is finished.
Solution:
NATIONAL UNIVERSITY OF COMPUTER AND EMERGING
SCIENCES
SE-220 – Software Design & Architecture Lab
LAB Instructors: Noureen Fatima

Lab 07

Outline
• To Understand Interaction Diagrams
• Sequence Diagram
• System Sequence Diagram
• Collaboration Diagram
• Exercise

Interaction Diagrams
The purpose of interaction diagrams is to visualize the interactive behaviour of the system.
Visualizing the interaction is a difficult task. Hence, the solution is to use different types of models
to capture the different aspects of the interaction.
Sequence and collaboration diagrams are used to capture the dynamic nature but from a different
angle.
The purpose of interaction diagram is −
• To capture the dynamic behaviour of a system.
• To describe the message flow in the system.
• To describe the structural organization of the objects.
• To describe the interaction among objects.
Interaction Diagram Example - Access Control System
• The Interaction Establish Access occurs first with argument “Illegal PIN" followed by
an interaction with the message Card Out which is shown in an inline Interaction.
• Then there is an alternative as we find a decision node with an Interaction Constraint
on one of the branches.
• Along that control flow we find another inline Interaction and an Interaction Use in the
sequence.

Example 01
The example shows a person who found ring bell for calling inside the room, being a person
he request to open the door. Door is digital they required face recondition
Sequence Diagram
• Sequence diagrams model the dynamic aspects of a software system.
• The emphasis is on the “sequence” of messages rather than relationship between objects.

• A sequence diagram maps the flow of logic or flow of control within a usage scenario into a visual
diagram enabling the software architect to both document and validate the logic during the analysis
and design stages.
• Sequence diagrams provide more detail and show the message exchanged among a set of
objects over time.

• Sequence diagrams are good for showing the behavior sequences of a diagram, shows only the
sequence of messages not their exact timing. It shows when and how long object is active/idle.

Purpose
• The main purpose of this diagram is to represent how different business objects interact.
• A sequence diagram shows object interactions arranged in time sequence.
• It depicts the objects and classes involved in the scenario and the sequence of messages
exchanged between the objects needed to carry out the functionality of the scenario.

When to use: Sequence Diagram


• Sequence diagram can be a helpful modeling tool when the dynamic behavior of objects needs to
be observed in a particular use case or when there is a need for visualizing the “big picture of
message flow”.
• A company’s technical staff could utilize sequence diagrams in order to document the behavior of
a future system.

• It is during the design period that developers and architects utilize the diagram to showcase
the system’s object interactions, thereby putting out a more fleshed out overall system design.
Self-Message
A self-messages can represent a recursive call of an operation, or one method calling
another method belonging to the same object. It is shown as creating a nested focus
of control in the lifeline’s execution occurrence.
Synchronous Calls
Synchronous messages only request operations, not signals. The message type is synchCall.
Synchronous messages wait for a response from the operation before resuming their behavior.
Synchronous messages are displayed as an arrow with a filled arrowhead.

Asynchronous Calls
Asynchronous messages of the type (MessageSort) asynchCall, connect to an operation and trigger
its execution. With asynchronous messages, the system does not wait for a response from the
recipient, but continues its processes without interruption. Operation parameters and message
attributes must match.
Lost and Found Messages
Lost messages are those that are either sent but do not arrive at the intended recipient, or which go to
a recipient not shown on the current diagram. Found messages are those that arrive from an
unknown sender, or from a sender not shown on the current diagram. They are denoted going to or
coming from an endpoint element

Example: Customer Cashier


This Sequence diagram illustrates the use of Combined Fragments in modelling a
simplified purchasing process. Cashiers scan items ensure that prices are quantities are
correct, and collect payments.
Alternative Combined Fragment
A Combined Fragment reflects one or more aspects of interaction (called interaction
operands) controlled by an interaction operator, with corresponding Boolean
conditions known as interaction constraints. The Fragment displays as a transparent
window, divided by horizontal lines for each operand.
Loop Combined Fragment. A loop fragment represents iteration through an
unknown number of items for purchase, after which the cashier requests payment.

System Sequence Diagram:


A system sequence diagram (SSD) is a sequence diagram that shows, for a
particular scenario of a use case, the events that external actors generate, their
order, and possible inter-system events.

Overview
System sequence diagrams are visual summaries of the individual use cases.
All systems are treated as a black box; the diagram places emphasis on events
that cross the system boundary from actors to systems. A system sequence
diagram should be done for the main success scenario of the use case, and
frequent or complex alternative scenarios.

A system sequence diagram should specify and show the following:


• External actors
• Messages (methods) invoked by these actors
• Return values (if any) associated with previous messages
• Indication of any loops or iteration area
Collaboration/Communication Diagram

Communication diagram is a kind of UML diagram that is designed for illustrating the
dynamic view of the system. It emphasizes the structural organization of the objects' send and
receive messages.In this example of the notation for a communication diagram, objects (actors
in use cases) are represented by rectangles. In the example (generic communication diagram):
• The objects are Object1, Object2, Object..., ObjectN-1 ..., and ObjectN.
• Messages passed between objects are represented by labeled arrows that start with the
sending object (actor) and end with the receiving object.
• The sample messages passed between objects are labeled 1: message1, 2: message2, 3:
message3, etc., where the numerical prefix to the message name indicates its order in
the sequence.
• Object1 first sends Object2 the message message1, Object2 in turn sends ObjectN-1 the
message message2, and so on.

Example-01 Communication Example - Hotel Reservation


• Each message in a communication diagram has a sequence number.
• The top-level message is numbered 1.
• Messages sent during the same call have the same decimal prefix, but suffixes of 1, 2, etc.
according to when they occur.
Example-02 Library Item Overdue
A Library Management System is a software built to handle the primary housekeeping functions of a
library. Libraries rely on library management systems to manage asset collections as well as
relationships with their members. Library management systems help libraries keep track of the books
and their checkouts, as well as members’ subscriptions and profiles.

Library management systems also involve maintaining the database for entering new books and
recording books that have been borrowed with their respective due dates.
NATIONAL UNIVERSITY OF COMPUTER AND EMERGING
Assa SCIENCES
SE-2002 – Software Design & Architecture Lab
LAB Instructors: Noureen Fatima “Noureen.Fatima @nu.edu.pk”

Lab 05

Outline
• To Understand Analysis Classes
• Control, Boundary, and Entity
• Robustness Analysis ECB Pattern
• Exercise

Analysis Class Stereotypes: Analysis classes represent an early conceptual model for ‘things
in the system which have responsibilities and behavior’. They eventually evolve into classes and
subsystems in the Design Model. The purpose of the Find Classes from Use-Case Behavior step
is to identify a candidate set of model elements (analysis classes) that will be capable of performing
the behavior described in the use case. Analysis classes may be stereotyped as one of the following:

Boundary classes
Control Classes
Entity classes

They are based on the model-view-controller concept, where the entity is the model, the control
is the controller, and the boundary is the view.

Use Case Analysis Classes Source Code Execute


Entity Class

The Role of an Entity Class: The main responsibilities of entity classes are to store
and manage information in the system.
Entity Class always as environment independent.
Example: Register for Courses (Create Schedule)

Entity

Control Class

Control objects (also known as controllers in MVC), which serve as


the “glue” between boundary objects and entity objects
Example: CreateMarketingCapmpaign is an example of a control
element for a customer service application. This design element
would be responsive to certain frontend boundary elements and would
collaborate with other entities, control elements, and backend boundary
elements to support the creation of a marketing campaign.

Boundary Class
A boundary class intermediates between the interface and something outside the system.
Boundary classes insulate the system from changes in the surroundings.
(for example, changes in interfaces to other systems and changes in user requirements),
keeping these changes from affecting the rest of the system.
The Role of a Boundary Class: A boundary class is used to model interaction between the
system's surroundings and it’s inner workings.

How to Create ECB Diagram in Papyrus

1) Create a papyrus class diagram as discussed in the previous lab. To include the stereotypes of
the ECB pattern, click on the right click on the class in the class diagram and go to
Profiles Update profile option

2) Suppose you want to create a class of entity stereotype. Under the update stereotype window,
type “entity” in qualified name and enter “ECB” in profile. When you do this, the entity will
automatically appear in the stereotype and qualified name will automatically change to
"ECB::entity".
Finally, click on + sign beside properties heading and change the name to “name” and value to
“entity” and click on ‘Ok’ as shown in the image below:

Example 01

Design a system for organizing championships of table games.

Requirements: verbal requirements.


British University Management System is a smart, flexible, and affordable
solution that covers all aspects of Universities, Colleges or Schools. It's a complete
end-to-end solution that covers every minute aspect of a university workflow which
we had used to perform manually.
There are four most important users who behave as Staff, Faculty, Administrator,
and Student.
Student will use the system for course registration after proper login with
creditionals student can also apply for scholarship on the basis on their financial
status and merit.
Office Staff are responsible for making class schedule for faculty members, then
faculty members run their classes according to defined scheduled
Faculty are responsible for assigning the grades and maintain the student’s
attendance with proper creditionals, they can also provide the suggestion/feedback
form their account for associated subject. Then all suitable changes are implemented
from administration for upcoming semester.
Administrator who are responsible to control all the operations that are performed
by different users.
British University Management System USE CASE Diagram
Actors:
Student
Staff
Faculty
Administrator(secondary actor)
Entity Classes Boundary Diagram for British University Management System

Robustness Diagram and Analysis Classes

User Id AppUC11
Use Case Name Apply for scholarship
Actor Applicant
Description Search for international Scholarship
Trigger The applicant want to search for foreign fully funded scholarship
Precondition Applicant start a web browsing
Postcondition Searched result meet with desirable criteria
Normal Flow 1. Applicant visit international scholarship websites
2. Applicant click on “apply scholarship” button
3. Listed scholarship page displayed from system
4. Applicant select fully funded scholarship and click apply button
5. System ask for all the academic and personal details
6. After system confirm his/her criteria and will give confirmation email.
Alternative There is no alternative way to apply for international scholarship
flows
Exception In step no 06, may system will not dent confirmation email to the applicant due
to any missing data.
Include None
Issue None
Robustness Diagram
1. Visit https://online.visual-paradigm.com/
2. Click on "Start Your Free Trial" within the edition table
3. Enter your email address in the Sign up page and click Sign up to create an online
workspace
4. Confirm the confirmation email we sent
5. Done! You can start creating your own drawing with the online drawing tool. Enjoy!
NATIONAL UNIVERSITY OF COMPUTER AND EMERGING
SCIENCES
SE-220 – Software Design & Architecture Lab
LAB Instructors: Noureen Fatima

Objective: To Understand Class Diagram

Class diagrams:
In software engineering, a class diagram in the Unified Modeling Language (UML) is a type of
static structure diagram that gives an overview of a system by showing the system's classes,
their attributes, operations (or methods), and the relationships among objects -- they display what
interacts but not what happens when they do interact.

Purpose of Class Diagrams:

1. Shows static structure of classifiers in a system


2. Diagram provides a basic notation for other structure diagrams prescribed by UML
3. Helpful for developers and other team members too
4. Shows static structure of classifiers in a system

Class Notation:
UML class notation is a rectangle divided into three parts: class name, attributes, and operations.

1. Class Name
 The name of the class appears in the first partition.

2. Class Attributes
 Attributes are shown in the second partition.

 The attribute type is shown after the colon.

 Attributes map onto member variables (data members) in code.

3. Class Operations (Methods)


 Operations are shown in the third partition. They are services the class provides.

 The return type of a method is shown after the colon at the end of the
method signature.

 The return type of method parameters is shown after the colon following
the parameter name.

 Operations map onto class methods in code


Example:

There are many animals in the zoo but you would model only one class called Animal, to represent
entire collection of animals.

Class name

Attributes

Operations

Class Information: Visibility and Scope

The class notation is a 3-piece rectangle with the class name, attributes, and operations. Attributes and
operations can be labeled according to access and scope. Here is a new, expanded Animal class

Public
Private

List of arguments

Return

Class scope
(static)
Symbol Access

+ public

- private

# protected

~ default

UML Class Diagrams Relationship:

There are following key relationships between classes in a UML class diagram:

1. Association
2. Generalization/ Inheritance
3. Realization/ Implementation
4. Dependency
5. Aggregation
6. Composition

These six relationships are depicted below

1. Association:

There is an association between two classes if an instance of one class must know about the other
in order to perform its work.
Example:

Student.class Course.class

public class Student { public class Course {

public Course course;


public String Email; public String CourseName;
public String Address;
public String Phone;
public String Name; public String getCourseName()
{ return CourseName;
public Course getCourse() }
{ return course;
}
public void setCourseName(String
public void setCourse(Course course) CourseName) {
{ this.CourseName =
this.course = course; CourseName;
} }
public void editCourse() {
public String getEmail()
{ return Email; }
}

public void setEmail(String Email) public void deleteCourse() {


{ this.Email = Email;
} }

public String getAddress()


{ return Address; public void addCourse() {
} }
public void
setAddress(String Address) { }
this.Address = Address;
}
}
Main.java
public class main {
public class main {

public static void main(String[] args) {


public static void main(String[] args) {

Student student = new Student();


Student student = new Student();

Course sda = new Course();


Course urdu = new Course();

sda.setCourseName("SDA");
urdu.setCourseName("SDA");
student.setCourse(sda);
student.setCourse(urdu);
Course savedCourse = student.getCourse();
Course savedCourse = student.getCourse();

System.out.println("Student Course: "+savedCourse.getCourseName());


} System.out.println("Student Course:
"+savedCourse.getCourseName());

Multiplicities Meaning

0..1 zero or one instance. The notation n . . m indicates n to m instances.

0..* or * no limit on the number of instances (including none).

1 exactly one instance

1..* at least one instance

2. Generalization/ Inheritance

An inheritance link indicating one class is a superclass of the other. A generalization


has a triangle pointing to the superclass.

Example: CheckingAccount and SavingAccount classes are inheriting BankAccount class


BankAccount.java

public class BankAccount {

private Integer accountNumber;


private Integer totalBalance;

public Integer getAccountNumber() {


return accountNumber;
}

public void setAccountNumber(Integer accountNumber)


{
this.accountNumber = accountNumber;
}

public Integer getTotalBalance() {


return totalBalance;
}

public void setTotalBalance(Integer totalBalance)


{ this.totalBalance = totalBalance;
}

public void getBalance() {


}

public void Deposit() {

public void withDraw() {


}

}
public class CheckingAccount extends public class SavingAccount extends
BankAccount { BankAccount {

private Integer Fees; private Integer interestRate;


public Integer getInterestRate()
CheckingAccount.java {SavingAccount.java

public Integer getFees() return interestRate;


{ return Fees; }
}
public void
setInterestRate(Integer interestRate)
public void { this.interestRate =
setFees(Integer Fees) { interestRate;
this.Fees = Fees; }
}
public void deductFee() {
} public void addInterest() {
}
} }
}
}

3. Realization/Implementation: Realization is the relationship between the interface and the

implementing class.

Example: Figure interface might specify method for area. The Rectangle and Circles classes need to

implement these methods, possibly in very different ways.


Shape.java Circle.java

public interface Shape { public class Circle implements Shape {

public Integer area(); public String length;


public Integer width;
} public String getLength() {
return length;

public void setLength(String length) {


this.length = length;

public Integer getWidth() {


return width;

public void setWidth(Integer width) {


this.width = width;

public Integer area() {


// TODO Auto-generated
method return null;

Rectangle.java

public class Rectangle implements Shape {


public Integer length;
public Integer width;

public Integer getLength() {


return length;
}

public void setLength(Integer length) {


this.length = length;
}

public Integer getWidth() {


return width;
}

public void setWidth(Integer width) {


this.width = width;
}

public Integer area() {

return null;
}

}
4. Dependency

A special type of association. Class1 depends on Class2

The figure below shows an example of dependency. The relationship is displayed as a dashed line
with an open arrow

Example: Customer is dependent on Account as its makingDeposit using the class variable Account.

class Account{

public void deposit{

class Customer{

public void makeDeposit (Account acc)

acc.deposit();

5. Aggregation

A special type of association.

 It represents a "part of" relationship.


 Class2 is part of Class1.
 The HAS-A relationship is based on usage, rather than inheritance.
 class A has-a relationship with class B, if class A has a reference to an instance of
class B

Example:

The Society class has an instance variable of type Student. As we have a variable of type
Student in the Society class, it can use Society reference which is ad in this case, to invoke
methods of the Student class.

Student.java

public class Student{


int id, roll_no, CNIC;

public Student(int id, int roll_no, int CNIC)


{ this.id = id;
this.roll_no = roll_no;
this.CNIC = CNIC;
}
}
Society.java

public class Society{


int year;
String name;
Student student;

public Society(int year, String name, int id, int roll_no, int CNIC)
{ this.year = year;
this.name = name;
this.student= new Student(id, roll_no, CNIC);
}
}

Composition

 A special type of aggregation where parts are destroyed when the whole is destroyed.
 Objects of Class2 live and die with Class1.
 Class2 cannot stand by itself.

Job.java

package com.journaldev.composition;
public class Job {
private String role;
private long salary;
private int id;
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public long getSalary() {
return salary;
}
public void setSalary(long salary) {
this.salary = salary;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}

}
Person.java

package com.journaldev.composition;
public class Person {
//composition has-a relationship
private Job job;
public Person(){
this.job=new Job();
job.setSalary(1000L);
}
public long getSalary() {
return job.getSalary();
}
}

Class Task
 Draw a class diagram of a campus library management
system. Attributes of library include name, phone number.
Library contains books and journals that can be added or
removed form the library.
 Each book and journal has an id, name, author name and
publisher.
 Library member can issue and return the book.
 Library member can be student or staff. Students can issue 4
books at a time and staff can have 8 books.
 Journals are available for staff only.

You might also like