From the exam batch: internet was OFF in lab 316 and ma'am watched from behind, so the site cannot be used there. Asked: use case + class diagram for Library Management System and Online Course System, and cyclomatic complexity. All experiments came except Exp 1 and Git. Draw each diagram 2-3 times in Dia at home until you can do it from memory.

DIA 5-step drill for any diagram (no internet needed)

  1. Open Dia. Left panel drop-down: UML (use case, class, activity, state) or Flowchart + Gane and Sarson (DFD, flow graph)
  2. Click a shape, click on the page, double-click it to type the text / fill attributes and operations
  3. Connect with the Line tool (top toolbox) or UML Association / Generalization / Dependency / Transition; ends turn red when connected
  4. Arrow heads: bottom-left arrow selector or double-click the line > Start / End arrow. Labels: T (Text) tool
  5. File > Save (.dia) and File > Export > PNG. Write name, roll no, date on the printout
DiagramPick in Dia
Use caseUML: Actor, Use case; Box tool for system boundary; Line for association; Dependency + stereotype include / extend
ClassUML: Class (Attributes / Operations tabs), Generalization (hollow triangle at parent), Association (name + multiplicity), Aggregation / Composition = Association > Type
DFDFlowchart: Ellipse (process), Box (entity); Gane and Sarson: Data Store; Line with end arrow + T label
ActivityUML: State Term (start / end, tick Is final), Activity, Branch (diamond), Fork (bar), Transition (Guard = [Yes])
StateUML: State Term, State, Transition (Trigger = event)
Flow graphFlowchart: Ellipse (small numbered circles), Line with end arrow, Box for the node list

LMS Library Management System

Members search, reserve, borrow and return books; the librarian issues / returns books and manages books and members; fine is charged for late return.

Actors: Member, Librarian (Admin optional). Classes: Person, Member, Librarian, Book, Loan, Fine.

Library Management SystemSearch BookReserve BookIssue BookReturn BookAdd / Update BookManage MembersCheck AvailabilityCalculate FineMemberLibrarian<<include>><<extend>>
Use case diagram: Library Management System (file: lms_usecase.dia in SE_Lab_Files.zip)
Person-id: int-name: String-email: String+login(): boolMember-memberType: String-maxBooks: int+searchBook(title:String): List+reserveBook(b:Book): voidLibrarian-shift: String+issueBook(m:Member,b:Book): Loan+returnBook(l:Loan): void+addBook(b:Book): voidLoan-loanId: int-issueDate: Date-dueDate: Date-returnDate: Date+calculateFine(): doubleBook-isbn: String-title: String-author: String-status: String+isAvailable(): boolFine-amount: double-paid: bool+pay(): voidborrows1*processes1*for*1has10..1
Class diagram: Library Management System (file: lms_class.dia in SE_Lab_Files.zip)
DFD Level 0: Library Management System: see SE_Practice.pdf / lms_dfd0.dia in SE_Lab_Files.zip
DFD Level 1: Library Management System: see SE_Practice.pdf / lms_dfd1.dia in SE_Lab_Files.zip
Activity diagram: Issue Book (with fork / join): see SE_Practice.pdf / lms_activity.dia in SE_Lab_Files.zip
State diagram: Book: see SE_Practice.pdf / lms_state.dia in SE_Lab_Files.zip

Viva

Actors in LMS?Member (student / faculty) and Librarian; Admin optional.
include example?Issue Book includes Check Availability (always done).
extend example?Calculate Fine extends Return Book (only when the book is late).
Why Person class?Member and Librarian share id, name, email, so they inherit from Person (generalization).
Multiplicity Loan to Fine?1 to 0..1: a loan has at most one fine.

OCS Online Course System

Instructors create courses and upload lectures, admin approves, students pay and enroll, watch lectures, take quizzes and download certificates.

Actors: Student, Instructor, Admin, Payment Gateway. Classes: User, Student, Instructor, Course, Lecture, Enrollment, Payment, Quiz.

Online Course SystemBrowse CoursesEnroll in CourseWatch LectureTake QuizDownload CertificateMake PaymentCreate CourseUpload LectureView ProgressApprove CourseManage UsersStudentInstructorAdminPayment Gateway<<include>><<extend>>
Use case diagram: Online Course System (file: ocs_usecase.dia in SE_Lab_Files.zip)
User-userId: int-name: String-email: String-password: String+login(): boolStudent-level: String+enroll(c:Course): Enrollment+takeQuiz(q:Quiz): intInstructor-expertise: String+createCourse(): Course+uploadLecture(l:Lecture): voidEnrollment-enrollDate: Date-progress: int+updateProgress(): voidCourse-courseId: int-title: String-price: double-status: String+publish(): voidPayment-paymentId: int-amount: double-status: String+process(): boolLecture-lectureId: int-title: String-videoUrl: StringQuiz-quizId: int-totalMarks: int+evaluate(): inthas1*teaches1*for*1paid by11contains1*has1*
Class diagram: Online Course System (file: ocs_class.dia in SE_Lab_Files.zip)
DFD Level 0: Online Course System: see SE_Practice.pdf / ocs_dfd0.dia in SE_Lab_Files.zip
DFD Level 1: Online Course System: see SE_Practice.pdf / ocs_dfd1.dia in SE_Lab_Files.zip
Activity diagram: Enroll in Course: see SE_Practice.pdf / ocs_activity.dia in SE_Lab_Files.zip
State diagram: Course: see SE_Practice.pdf / ocs_state.dia in SE_Lab_Files.zip

Viva

Actors in Online Course System?Student, Instructor, Admin, and Payment Gateway (external system actor).
include example?Enroll in Course includes Make Payment.
extend example?Download Certificate extends Take Quiz (only if passed).
Composition example?Course contains Lectures (filled diamond): lectures cannot exist without the course.
Course states?Draft, Under Review, Published, Rejected, Archived.

CC Cyclomatic complexity (white box)

MethodFormula
Edges and nodesV(G) = E - N + 2
Predicate (decision) nodesV(G) = P + 1
RegionsV(G) = closed regions + 1 (outer)
  1. Number every statement / condition (merge simple sequential statements into one node)
  2. Draw the flow graph (circles + arrows)
  3. Count E, N, P and find V(G) by all 3 methods (they must match)
  4. Write V(G) independent paths
  5. One test case per path: input, expected, actual, pass / fail

Program 1: largest of three numbers (nested if)

largest.py
def largest(a, b, c):
    if a > b:              # node 2
        if a > c:          # node 3
            m = a          # node 4
        else:
            m = c          # node 5
    else:
        if b > c:          # node 6
            m = b          # node 7
        else:
            m = c          # node 8
    return m               # node 9

tests = [("TC1", 5, 3, 2, 5), ("TC2", 5, 3, 7, 7), ("TC3", 2, 6, 3, 6), ("TC4", 2, 6, 9, 9)]
for tc, a, b, c, exp in tests:
    got = largest(a, b, c)
    print(tc, (a, b, c), "expected", exp, "actual", got, "PASS" if got == exp else "FAIL")
123645789TFTFTF1 read a, b, c2 a > b ?3 a > c ?4 max = a5 max = c6 b > c ?7 max = b8 max = c9 print maxE = 11, N = 9, P = 3V(G) = E - N + 2 = 4V(G) = P + 1 = 4Regions = 4
Flow graph: largest of three (file: cc_largest.dia in SE_Lab_Files.zip)

E = 11, N = 9, predicate nodes P = 3 (2, 3, 6) > V(G) = 11 - 9 + 2 = 4 = P + 1 = 4 = regions 4

TestIndependent pathInputExpected
TC11-2-3-4-9a=5, b=3, c=25
TC21-2-3-5-9a=5, b=3, c=77
TC31-2-6-7-9a=2, b=6, c=36
TC41-2-6-8-9a=2, b=6, c=99

Program 2: sum of even numbers 1..n (while loop)

even_sum.py
def even_sum(n):
    i, s = 1, 0            # node 1
    while i <= n:          # node 2
        if i % 2 == 0:     # node 3
            s = s + i      # node 4
        i = i + 1          # node 5
    return s               # node 6

tests = [("TC1", 0, 0), ("TC2", 1, 0), ("TC3", 4, 6)]
for tc, n, exp in tests:
    got = even_sum(n)
    print(tc, "n =", n, "expected", exp, "actual", got, "PASS" if got == exp else "FAIL")
Flow graph: sum of even numbers (loop): see SE_Practice.pdf / cc_loop.dia in SE_Lab_Files.zip

E = 7, N = 6, P = 2 (2, 3) > V(G) = 7 - 6 + 2 = 3 = P + 1 = 3. A loop is one decision.

TestIndependent pathInputExpected
TC11-2-6 (loop skipped)n=00
TC21-2-3-5-2-6 (odd only)n=10
TC31-2-3-4-5-2-... -6 (even added)n=46

Program 3: binary search

binary_search.py
def binary_search(a, key):
    low, high = 0, len(a) - 1      # node 1
    while low <= high:             # node 2
        mid = (low + high) // 2    # node 3
        if a[mid] == key:          # node 4
            return mid             # node 5
        elif key < a[mid]:         # node 6
            high = mid - 1         # node 7
        else:
            low = mid + 1          # node 8
    return -1                      # node 9  (node 10 = end)

tests = [("TC1", [], 5, -1), ("TC2", [1, 3, 5], 3, 1), ("TC3", [3], 1, -1), ("TC4", [3], 7, -1)]
for tc, a, k, exp in tests:
    got = binary_search(a, k)
    print(tc, a, "key", k, "expected", exp, "actual", got, "PASS" if got == exp else "FAIL")
Flow graph: binary search: see SE_Practice.pdf / cc_bsearch.dia in SE_Lab_Files.zip

E = 12, N = 10, P = 3 (2, 4, 6) > V(G) = 12 - 10 + 2 = 4 = P + 1 = 4

TestIndependent pathInputExpected
TC11-2-9-10a=[], key=5-1
TC21-2-3-4-5-10a=[1,3,5], key=31
TC31-2-3-4-6-7-2-9-10a=[3], key=1-1
TC41-2-3-4-6-8-2-9-10a=[3], key=7-1

Viva

What is cyclomatic complexity?Number of linearly independent paths in a program = minimum number of test cases for basis path testing (McCabe).
3 ways to find V(G)?1) E - N + 2 2) P + 1 (P = predicate / decision nodes) 3) number of regions (closed areas + outside).
What is a predicate node?A node with a condition (if / while / for / case) that has 2 or more outgoing edges.
What is a region?An area of the flow graph bounded by edges and nodes; the outside area also counts as one region.
Why is it useful?Tells how many test cases are needed and how complex / risky the code is. V(G) > 10 = hard to test, split the module.
How is a loop counted?while / for = one decision. A switch with k cases adds k - 1.
What is basis path testing?White-box method: draw flow graph, find V(G), list V(G) independent paths, write one test case per path.
Compound condition (a && b)?Split into separate decision nodes; each simple condition is one predicate node.

COCOMO Cost estimation (Exp 4)

COCOMO = COnstructive COst MOdel by Barry Boehm (1981). It estimates effort (person-months), time (months), people and cost from the size of the software in KLOC (thousand lines of code).

ModeProject typeabcd
OrganicSmall, simple, experienced team (LMS, OMS)2.41.052.50.38
Semi-detachedMedium size, mixed team (Online Course)3.01.122.50.35
EmbeddedComplex, strict hardware / real-time limits (ATM, flight control)3.61.202.50.32
Basic COCOMO formulas
Effort    E = a x (KLOC)^b      person-months (PM)
Duration  D = c x (E)^d         months
People    P = E / D
Cost        = E x salary per person-month
ExampleLMS: 8 KLOC, organicOMS: 12 KLOC, organicOnline Course: 20 KLOC, semi-detached
Effort E2.4 x 8^1.05 = 21.30 PM2.4 x 12^1.05 = 32.61 PM3.0 x 20^1.12 = 85.96 PM
Duration D2.5 x 21.30^0.38 = 7.99 months2.5 x 32.61^0.38 = 9.40 months2.5 x 85.96^0.35 = 11.88 months
People P21.30 / 7.99 = 2.67 (~3)3.47 (~4)7.23 (~7)
Cost at Rs 50,000 / PMRs 10.65 lakhRs 16.31 lakhRs 42.98 lakh

3 types of COCOMO

TypeWhat it adds
BasicOnly size (KLOC) and mode. Quick rough estimate.
IntermediateE = a x KLOC^b x EAF. EAF (effort adjustment factor) = product of 15 cost drivers (product, hardware, personnel, project attributes, e.g. reliability, team experience, tools). a = 3.2 / 3.0 / 2.8.
DetailedApplies cost drivers to each phase (design, code, test) separately.

COCOMO II (1995): newer version with 3 sub-models: application composition (object points), early design, post-architecture. Uses KLOC or function points.

Function points (size without code)

Function point steps
1. Count: EI (inputs), EO (outputs), EQ (inquiries), ILF (internal files), EIF (external files)
2. UFP = sum of count x weight   (average weights: EI 4, EO 5, EQ 4, ILF 10, EIF 7)
3. Rate 14 general system characteristics 0-5, add them = sum Fi
4. VAF = 0.65 + 0.01 x sum Fi
5. FP = UFP x VAF

LMS: EI 5, EO 3, EQ 3, ILF 3, EIF 1
UFP = 5x4 + 3x5 + 3x4 + 3x10 + 1x7 = 84
sum Fi = 38  ->  VAF = 0.65 + 0.38 = 1.03
FP = 84 x 1.03 = 86.52

In the lab: open Exp4_Cost_Estimation.xlsx (SE_Lab_Files.zip) in LibreOffice Calc, change KLOC / mode / counts, everything recalculates. Or run cost.py.

Viva

What is COCOMO?Constructive Cost Model by Boehm; estimates effort, time, people and cost from KLOC.
3 modes?Organic (small, simple), semi-detached (medium), embedded (complex, strict constraints).
3 types / levels?Basic, intermediate (with 15 cost drivers / EAF), detailed (per phase).
Unit of effort?Person-months (PM): work done by one person in one month.
What is KLOC?Thousand lines of code: the size input of COCOMO.
What is EAF?Effort adjustment factor = product of the 15 cost driver ratings (intermediate COCOMO).
What is a function point?Size measure based on functionality (inputs, outputs, inquiries, files), independent of language.
LOC vs FP?LOC depends on language and is known only after coding; FP is language independent and known early.
Other estimation methods?Expert judgement, Delphi, Putnam (SLIM) model, function points, use case points.
Why estimate cost?To plan budget, schedule and team size before starting the project.

FILES Software in the lab manual and ready files

SoftwareUsed inHowFile in SE_Lab_Files.zip
Dia Diagram EditorExp 1, 5, 6, 7, 10 (process model, use case, class, DFD, activity, state, flow graph)Ubuntu: Activities > Dia (sudo apt install dia). File > Open the .dia file. File > Export > PNG1_Dia/*.dia
GanttProjectExp 3 project plan / Gantt chart (ProjectLibre can import the same plan)Project > Open > .gan file. Chart tab shows the bars; Resources tab shows people. Project > Export > PNG / PDF2_GanttProject/*.gan (+ .csv: Project > Import)
LibreOffice Calc / MS ExcelExp 4 cost estimation, Exp 8 RMMM table, Exp 10 test case formatOpen the .xlsx; formulas calculate automatically. Change KLOC / counts and everything updates3_Calc/*.xlsx
LibreOffice Writer / MS WordExp 1 problem statement, Exp 2 SRS (IEEE 830)Open the .docx and edit the project name4_Writer/*.docx
Git + GitHubExp 9 version controlTerminal: run the commands in git_commands.txt one by one5_Git/git_commands.txt
Python 3Exp 4 calculator, Exp 10 test programsTerminal: python3 file.py6_Python/*.py

Full folder (all .dia, .gan, .xlsx, .docx, .py, git commands): SE_Lab_Files.zip (sent in chat). Office Management System full guide with every experiment: optezum.live/oms.