Problems

CMSE321 Problem session 04.01.2016
Online Dormitory Management System
UC1. Student can view available rooms for gender, start date, end date
UC2. Student can select a room
UC3. Student can book a selected room specifying start date, end date, payment
UC4. Manager can view student information (living in a particular room for specified dates)
1. Logics in requirements
P1=user is a student
P2=user is a manager
P3=button ‘View available rooms” is pressed
P4=request for gender, start, end dates is displayed
P5=gender, start, end dates are entered
P6=available rooms from DB for the gender, start, end dates are displayed
P1&p2=>p4
P4&p5=>p6
Lec-10, slides 34-38
2. OCL (Object Constraint Language)
Context Dormitory inv1:inv
Self.available_room_no(t)+self.reserved_room_no(t)==self.rooms_total;
Inv2:inv
Self.used_room_no(t)+self.not_used_room_no(t)==self.rooms_total;
Inv3:inv
Self.used_room_no(t)<=self.reserved_room_no(t);
Context Dormitory::book_room(rm:room; start, end: date)
Boolean pre1:pre
Rm->forAll(t:t>=start&t<=end&~rm.booked(t));// ~ denotes negation, & conjunction
Boolean post1:post
Rm->forAl(t:t>=start&t<=end&rm.booked(t));
Lec-11, slides 20-22
3. Use Case Points
Actors: Student, Manager use GUI => Complex => weight=3 (Lec-14, slide 9)
TF
W
F
1
Distribu
ted
system
2
5
Unadjusted Actor Weight (UAF) =1*3+1*3=6
UC1 – simple => 5
UC2 – simple => 5
UC3 – average => 10
UC4 – average => 10
Unadjusted UC Weight (UUCW) = 2*5+2*10=30
Unadjusted UC Point (UUCP) = UAF+UUCW=6+30=36
Technical Complexity Factor=c1+c2*sum(Wi*Fi,i=1,13) scale=0..5
2
3
4
5
6
7
8
9
Perfor End- Comple Reusa Easy
Easy
Porta Easy
mance user x
ble
to
to use ble
to
critical effici internal design install
chang
ency processi or
e
ng
code
1
3
1
3
1
3
1
4
0.5
4
0.5
4
2
4
1
4
10
Conc
urre
nt
use
11
Special
securit
y
featur
es
12
Provides
direct
access
to third
parties
1
5
1
4
1
0
TCF=c1+c2*sum(Wi*Fi,i=1,13), c1=0.6, c2=0.01 Lec-14, Slides 13-17
TCF=0.6+0.01*(10+3+3+3+4+2+2+8+4+5+4+0+0)=0.6+0.01*48=1.08
Environmental Complexity Factor (Slides 18-20) scale=0..5
1
2
3
4
5
6
ECF Familiar
Application Paradigm
Lead
Motiva Stable
with the
problem
experience analyst
tion
requir
developme experience
capability
ement
nt process
s
W
1.5
0.5
1
0.5
1
2
F
4
4
4
4
3
5
ECF=c1+c2*sum(Wi*Fi,i=1,8), c1=1.4, c2=-0.03
ECF=1.4-0.03*(6+2+4+2+3+10-3-3)=1.4-0.03*21=1.4-0.63=0.77
UCP=UUCP*TCF*ECF=36*1.08*0.77=29.94=30
Duration=UCP/Productivity
4. Cyclomatic Complexity Lec-15 slide 5
V(G)=e-n+2, e is a number of edges, n is a number of nodes
Sort(A,n){
For(i=1,n-1){
Min=Ai; imin=I;
For(j=i+1,n){
If(min>Aj){
Min=Aj; imin=j;
}//end if
}//end for j
13
Special
user
training
facilities
are
requires
1
0
7
Parttime
staff
8
Difficult
programming
language
-1
3
-1
3
If(imin<>i){
Temp=Ai; Ai=Aimin; Aimin=temp;
}//end if
}//end for i
}//end sort
Its flowchart:
1 start
2 Min=Ai;
Imin=i
12 end
3 j=i+1
0
1
5 Min=Aj;
Imin=j
4 Min>Aj
11 i<n
1
0
6 j=j+1
10 i=i+1
0
0
7 j<=n
1
Its graph:
8 imin<>i
1
9 temp=Aj;
Ai=Aj; Aj=temp
E15
E13
1
10
11
E11
E1
2
E16
E14
12
9
E2
E10
3
8
E12
E3
E9
E8
4
7
E6
E4
5
E7
6
E5
V(G)=e-n+2=16-12+2=6
P1=e1,e2,e3,e6,e7,e9,e12,e13,e14,e16
P2=e1,e2,e3,e4,e5,e7,e9,e12,e13,e14,e16
P3=e1,e2,e3,e6,e7,e8,e6,e7,e9,e12,e13,e14,e1
6
P7=e1,e2,e3,e4,e5,e7,e8,e4,e5,e7,e9,e12,e13,
e14,e16
P4=e1,e2,e3,e6,e7,e9,e10,e11,e13,e14,e16
P5=e1,e2,e3,e6,e7,e8,e4,e5,e7,e9,e12,e13,e14,e16
P6=e1,e2,e3,e6,e7,e9,e12,e13,e15,e2,e3,e6,e7,e9,e12,e1
3,e14,e16
Vector path representation
E1
E2
E3
E4
E5
E6
E7
P1 1
1
1
1
1
P2 1
1
1
1
1
1
P3 1
1
1
2
2
P4 1
1
1
1
1
P5 1
1
1
1
1
1
2
P6 1
2
2
2
2
P7 1
1
1
2
2
2
P7=a1*p1+a2*p2+a3*p3+a4*p4+a5*p5+a6*p6
(1) A1+a2+a3+a4+a5+a6
=1
(2) A1+a2+a3+a4+a5+2*
a6=1
(2) A1+a2+a3+a4+a5+2*
a6=1
(3) A2+a5=2
a5+a2=2 (3)
a1+2*a3+a4+a5+2*a6
=0 (4)
a1+a2+2*a3+a4+2*a5
+2*a6=2 (5)
a3+a5=1 (6)
E8
1
1
1
E9
1
1
1
1
1
2
1
E10
E11
1
1
(2) a1+a2+a3+a4+a5+2*
a6=1
a4=0 (7)
E12
1
1
1
1
2
1
E13
1
1
1
1
1
2
1
E14 E15 E16
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
a4=0 (7)
A1+a2+a3+a4+a5+2*a
6=1 (2)
(1) A1+a2+a3+a4+a5+
a6=1
A6=0 (9)
A1+a2+a3+a5+2*a6=1
(8)
(1) A1+a2+a3+a4+a5+
a6=1
From (3), A2=2-a5;
From (6), a3=1-a5;
From (7), a4=0;
From (9), a6=0;
From (1), A1+2-a5+1-a5+0+a5+0=1 =>a1=a5-2;
From (4), a1+2*(1-a5)+0+a5+0=0 => a1=a5-2
From (5), a5-2+2-a5+2*(1-a5)+0+0=2 =>a5=0 =>a1=-2; a3=1; a2=2
A1=-2;a2=2;a3=1;a4=0;a5=0;a6=0
P7=-2*P1+2*P2+P3
5. Cohesion Metrics
Class C9 Lec-16 Metrics Cohesion, Slide 22
LCOM1 = Number of pairs of methods that
do not share attributes
Lack of Cohesion of Methods (LCOM)
LCOM1=3? LCOM1=P=6-Q=6-(1+1+1+1)=6-4=2
P – Q, if P – Q  0
P = Number of pairs of methods that do not share attributes
Q = Number of pairs of methods that share attributes
LCOM2
0, otherwise
LCOM2=0; P=2, Q=4, P-Q=-2 =>LCOM2=0
LCOM3=1; LCOM3 = Number of disjoint components in the graph that represents each method as a node and the
sharing of at least one attribute as an edge
LCOM4=1; Similar to LCOM3 and additional edges are used to represent method invocations
LCOM5=2/3; LCOM5 = (a – kℓ) / (ℓ – kℓ), where ℓ is the number of attributes, k is the number of methods, and a is
the summation of the number of distinct attributes accessed by each method in a class
A=2+2+3+1=8; LCOM5=(8-4*4)/(4-4*4)=-8/(-12)=2/3
Coh=1/2; Coh = a / kℓ, where a, k, and ℓ have the same definitions as above; Coh=8/(4*4)=1/2
TCC=1/2? Tight Class Cohesion (TCC) = Fraction of directly connected pairs of methods, where two methods are
directly connected if they are directly connected to an attribute. A method m is directly connected to an
attribute when the attribute appears within the method’s body or within the body of a method invoked by
method m directly or transitively; TCC=4/6=2/3
Loose Class Cohesion (LCC)
LCC=3/6? LCC = Fraction of directly or transitively connected pairs of methods, where two methods are transitively
connected if they are directly or indirectly connected to an attribute. A method m, directly connected to an
attribute j, is indirectly connected to an attribute i when there is a method directly or transitively connected
to both attributes i and j
LCC=6/6
DCD=3/6?; Degree of Cohesion Direct DCD = Fraction of directly connected pairs of methods, where two methods are
directly connected if they satisfy the condition mentioned above for TCC or if the two methods directly or
transitively invoke the same method
DCD=4/6;
DCI=5/6; Degree of Cohesion Indirect DCI = Fraction of directly or transitively connected pairs of methods, where two
methods are transitively connected if they satisfy the condition mentioned above for LCC or if the two
methods directly or transitively invoke the same method
Class Cohesion CC = Ratio of the summation of the similarities between all pairs of methods to the total number of
pairs of methods. The similarity between methods i and j is defined as:
where, Ii and Ij are the sets of attributes referenced by methods i and j
Similarity(i, j) =
| Ii  Ij |
| Ii  Ij |
S12=1/3; S13=1/4; S14=0;S23=1/4; S24=0; S34=1/3; CC=(1/3+1/4+1/4+1/3)/6=7/36
SCOM = Ratio of the summation of the similarities between all pairs of methods to the total number of pairs of
methods. The similarity between methods i and j is defined as:
| Ii  Ij |
Similarity(i, j)
min(| Ii |, | Ij |)
.
| Ii  Ij |
where, ℓ is the number of attributes
ℓ
Similarity class Cohesion of Methods
S12=1*3/(min(2,2)*4)=3/8;S13=1*4/(min(2,3)*4)=1/2;S14=0;S23=1*4/(min(2,3)*4)=1/2;S24=0;S34=1*3/(min(1,3)*4)
=3/4
SCOM=(3/8+1/2+1/2+3/4)/6=17/48;
Low-level design Similarity based Class Cohesion
LSCC(C) =
0
if k = 0 or ℓ = 0
1
if k = 1
ℓ
x (x – 1)

i=1
i
i
otherwise
ℓk (k – 1)
where ℓ is the number of attributes, k is the number of methods, and xi is the number of methods
that reference attribute i
X1=2,x2=2,x3=2,x4=2; LSCC=(2+2+2+2)/(4*4*3)=8/48=1/6
Cohesion Among Methods in a Class (CAMC) CAMC = a/kℓ, where ℓ is the number of distinct parameter types, k is
the number of methods, and a is the summation of the number of distinct parameter types of each method
in the class. Note that this formula is applied on the model that does not include the “self” parameter type
used by all methods
M1(int,float), m2(float, float), m3((int, string), m4(string, string)
X1=2, x2=1, x3=2, x4=1, CAMC=(2+1+2+1)/(4*3)=6/12=1/2
Normalized Hamming Distance (NHD)
2
NHD = 1 –
ℓ
 x (k – x )
ℓk (k – 1) j=1
j
j
where k and ℓ are defined above for CAMC and xj is the number of methods that have a parameter of type j
x(int)=2; x(float)=2; x(string)=2 NHD=1-2(2*2+2*2+2*2)/(3*4*3)=1-24/36=1-2/3=1/3
6. Function Points (Software Metrics)
External Inputs – Press “View rooms”, “View students”
External Outputs – available rooms, student information
External Inquiries – select room(gender, start, end); student info(time)
Internal Logical Files – DB Dormitory: 1) students; 2) rooms; 3) students living in rooms; 4) rooms reserved
by students for a time period
EInp=2; EOut=2; EInq=2; ILF=4; EIF=0 Average complexity each
Count total=2*4+2*5+2*4+4*10=66
FP=count total*(0.65+0.01*sum(Fi, i=1,14)), Fi are from 0..5
Question
1. Backup and recovery
2. Data communications
3. Distributed processing
4. Performance critical
5. Existing operating
environment
6. Online data entry
7. Input transaction over
multiple screens
8. ILFs updated online
9. Information domain
values complex
10. Internal processing
Estimate
4
3
3
3
3
4
2
5
3
3
11.
12.
13.
14.
complex
Code designed for
reuse
Conversion/installation
in design
Multiple installations
Application designed
for change
Total:
3
3
2
4
45
FP=66*(0.65+0.01*45)=66*1.1=73
LOC in C:
LOC=73*162=11826=12000
Object Points
1. Screens – view menu, view rooms, reserve, students inquiry, students info - 5
2. Reports – no
3. Components – screens+DB+payment calculation - 7
Average complexity all
Object points = 5*2=10
%reuse=0
NOP=object points*(1-%reuse/100)=10
Developer’s experience/capability nominal; Environmental maturity nominal
Productivity= 13 NOP/person-month
Estimated effort=1 person-month
COCOMO81
Model Simple A=2.4, B=1.05
Effort=2.4*(12)1.05=33 person-months
Software Equation
E=(LOC*B0.333/P)3*(1/t4), LOC=12000, P=28000, B=0.16; t=1 month; E=0.013 person/month
Tmin=8.14*(LOC/P)0.43 for tmin>6 months
8.14*(12000/28000)0.43=5.65 months
E=180*B*t3=180*0.16*0.53=3.6 person-months