OOAD - Object Oriented Analysis & Design, Past Papers, UOS Main Campus

Object Oriented Analysis and Design Past Paper 2016 – BS IT 5th Term UOS (SE-3311)

ProgramBS IT
Term5th
Year2016
Course codeSE-3311
AnswersSolved ✓

University of Sargodha BS IT 5th term Object Oriented Analysis & Design (SE-3311) paper, 2016 exam (80 marks, 2:30 hours). The paper is retyped below without the handwritten number, followed by solved answers for all 16 short questions and all five subjective questions on the hospital management case study: sequence diagrams for test appointment and bed allotment, a class diagram, state machine diagrams for patient, doctor and receptionist, activity diagrams and the Gang of Four patterns.

Solved answers

Q1 – Short answers (16 × 2)

i. Last phase of RUP. The Transition phase: beta testing, user training, data conversion, deployment/installation at the user site, fixing defects and getting user acceptance – the product moves from developers to users.

ii. Base class vs super class. Both mean the class from which another class inherits (Vehicle for Car). “Base class” is C++ terminology; “superclass” is Java/UML terminology. The inheriting class is the derived class / subclass.

iii. Inheritance and encapsulation. Inheritance: a class acquires attributes and operations of another class (is-a relation), e.g. Doctor inherits from Employee. Encapsulation: data and the methods that operate on it are bundled in a class and the data is hidden (private) behind a public interface.

iv. Object modelling. Describing a system as objects and classes with their attributes, operations and relationships (association, aggregation, inheritance), usually with UML class and object diagrams – the static structure of the system.

v. Latest version of UML. UML 2.5.1 (OMG, December 2017) is the latest official version.

vi. Merge vs decision node. A decision node (diamond) has one incoming flow and several outgoing flows with guards – only one path is taken. A merge node (diamond) has several incoming alternative flows and one outgoing flow – it brings alternative paths back together (no synchronisation, unlike join).

vii. Trigger in a state machine diagram. The event that causes a transition from one state to another, written on the transition as event [guard] / action, e.g. cardInserted moves an ATM from Idle to Reading Card.

viii. What a method describes. A method describes the behaviour of a class – what an object of that class can do or how it responds to a message (its implementation of an operation), e.g. Patient.register().

ix. Composition. A strong whole-part relationship in which the part cannot exist without the whole and is deleted with it, shown by a filled diamond at the whole, e.g. Hospital ◆— Ward, House ◆— Room.

x. Two non-functional requirements for banking software. (1) Security – all transactions encrypted and users authenticated with two-factor authentication. (2) Performance/availability – 99.9 % uptime and a transaction completes in under 2 seconds. (Others: reliability, auditability.)

xi. Three benefits of UML. A standard visual language understood by all stakeholders; models a system from many views (structure and behaviour) before coding; supports documentation, code generation and reverse engineering with tools.

xii. Post-conditions (use case). The conditions that must be true after the use case completes successfully, e.g. for “Book appointment”: an appointment record is saved and the patient receives the time and number.

xiii. 1..* relationship. One object of class A is linked to one or many objects of class B. Example: Doctor 1 ———— 1..* Patient – a doctor treats at least one and possibly many patients; each patient (here) has one doctor.

xiv. Support of a package diagram. It groups model elements (classes, use cases) into packages and shows dependencies between them, which helps organise large models, manage complexity, divide work among teams and show layered architecture.

xv. Coupling – is it good? Coupling is the degree of dependence between classes/modules. Low (loose) coupling is good – changes in one class affect few others; high coupling is bad because it makes the system hard to change, test and reuse.

xvi. Swimlanes. Partitions (vertical or horizontal lanes) in an activity diagram that show which actor, department or object is responsible for each activity, e.g. lanes for Patient, Receptionist and Doctor.

Q2 – Sequence diagrams: test appointment and bed allotment

(a) Patient test appointment

:Patient     :Receptionist     :HMS System      :LabTest       :Database
   |               |                  |                |               |
   |--requestTest->|                  |                |               |
   |  (patientID)  |--verifyID(id)--->|                |               |
   |               |                  |--findPatient(id)-------------->|
   |               |                  |<--------patient record---------|
   |               |                  |--checkSlot(test)->|            |
   |               |                  |<--freeSlot(time)--|            |
   |               |                  |--bookTest(id,slot)------------>|
   |               |                  |<--------appointment no.--------|
   |               |<--time & number--|                |               |
   |<-appointment--|                  |                |               |
   |   slip        |                  |                |               |
   |------------------------ undergoTest(id) --------->|               |
   |               |                  |<--saveResult---|               |
   |               |                  |--storeResult(id,result)------->|

(b) Bed allotment

:Doctor      :Receptionist     :HMS System       :Ward/Bed       :Database
   |               |                  |                 |               |
   |--admit(pID)-->|                  |                 |               |
   |               |--requestBed(pID)>|                 |               |
   |               |                  |--checkID(pID)--------------------->|
   |               |                  |<-----------valid patient---------|
   |               |                  |--findFreeBed(ward)->|            |
   |               |                  |<---bedNo / none-----|            |
   |               |                  |  alt [bed available]            |
   |               |                  |--allotBed(pID,bedNo)->|          |
   |               |                  |--saveAllotment-------------------->|
   |               |<--bed no, ward---|                 |               |
   |               |                  |  [else] addToWaitingList(pID)   |
   |<--confirmation|                  |                 |               |

Lifelines are drawn as dashed vertical lines under each object, messages as solid arrows, returns as dashed arrows, and the alt combined fragment shows the bed-available / not-available choice.

Q3 – Class diagram of the hospital management system

                    +-------------------+
                    |  Person {abstract}|
                    | -name -address    |
                    | -phone -gender    |
                    +---------^---------+
               +--------------+--------------+
     +---------+--------+          +---------+--------+
     |     Patient      |          |    Employee      |
     | -patientID       |          | -empID -salary   |
     | -dob             |          | +drawSalary()    |
     | +register()      |          +----^--------^----+
     | +payBill()       |               |        |
     +--+---+---+---+---+        +------+--+  +--+-----------+
        |   |   |   |            | Doctor  |  | Staff        |
        |   |   |   |            | -spec   |  | -role        |
        |   |   |   |            |+diagnose|  | (Receptionist|
        |   |   |   |            |+prescribe  |  Nurse, ...) |
        |   |   |   |            +----+----+  +--------------+
        |   |   |   |  1..*   *       | 1
        |   |   |   +---- Appointment +   (-apptNo -date -time)
        |   |   |  1..*
        |   |   +------ TestAppointment * ---- 1 LabTest (-testName -result)
        |   | 0..1
        |   +------ BedAllotment * ---- 1 Bed * ----<> 1 Ward * ----<> 1 Hospital
        | 1..*
        +------ Bill 1 ---- 1..* Payment {abstract}
                                  ^ CreditCard   ^ Cash   ^ Cheque

Patient 1 <>---- 1 MedicalHistory 1 <>---- * Diagnosis
Diagnosis 1 ---- * Prescription * ---- * Medicine
Patient 1 ---- 0..1 DischargeSummary
(<> = filled diamond / composition,  ^ = generalization)
  • Inheritance: Patient and Employee are Persons; Doctor and Staff (receptionist, nurse) are Employees; CreditCard, Cash and Cheque are kinds of Payment.
  • Associations/multiplicities: a patient has 1..* appointments with doctors; a doctor has many appointments; a patient can have many test appointments for lab tests; a patient has at most one current bed allotment.
  • Composition: Hospital ◆ Ward ◆ Bed; Patient ◆ MedicalHistory (deleted with the patient record).
  • Key operations: Patient.register(), generateID(); Receptionist.giveAppointment(); Doctor.diagnose(), prescribeTest(), prescribeMedicine(); Ward.allotBed(), transfer(); Bill.calculate(); DischargeSummary.generate().

Q4 – State machine diagrams

Patient

[*] --> Registered : register / generate ID
Registered --> AppointmentBooked : getAppointment
AppointmentBooked --> UnderConsultation : visitDoctor
UnderConsultation --> UnderTest : testPrescribed
UnderTest --> UnderConsultation : resultReady
UnderConsultation --> Admitted : admit [bed available] / allotBed
UnderConsultation --> Discharged : treatment complete (OPD)
Admitted --> InOperation : operationScheduled
InOperation --> Admitted : operationDone
Admitted --> Admitted : transferWard / updateBed
Admitted --> Discharged : discharge / generateSummary
Discharged --> BillPaid : payBill [cash | card | cheque]
BillPaid --> [*]

Doctor

[*] --> Available : login / dutyStart
Available --> Consulting : patientArrives
Consulting --> Diagnosing : examine
Diagnosing --> Prescribing : diagnosisMade
Prescribing --> Available : prescriptionSaved
Available --> InOperation : operationScheduled
InOperation --> Available : operationComplete
Available --> OnWardRound : roundTime
OnWardRound --> Available : roundDone
Available --> OffDuty : dutyEnd
OffDuty --> [*]

Receptionist

[*] --> Idle : login
Idle --> Registering : newPatientArrives
Registering --> Idle : ID generated
Idle --> SchedulingAppointment : appointmentRequest
SchedulingAppointment --> Idle : time & number issued
SchedulingAppointment --> Idle : no slot / offerNextDate
Idle --> AllottingBed : admissionRequest
AllottingBed --> Idle : bed allotted / waiting list
Idle --> ProcessingBill : patientPays
ProcessingBill --> Idle : receiptIssued
Idle --> [*] : logout

Each state is drawn as a rounded rectangle, [*] is the filled initial/final circle, and transitions are labelled event [guard] / action.

Q5 – Activity diagram and its elements

An activity diagram is a UML behaviour diagram that shows the flow of control (and data) from activity to activity – like an advanced flowchart that also supports parallel flows. It is used to model business processes/workflows, the steps of a use case, and complex algorithms.

ElementNotationPurpose
Initial nodefilled black circlestart of the flow
Action / activityrounded rectanglea step of work, e.g. “Register patient”
Control flow (edge)arroworder of actions
Decision nodediamond, one in – many out with [guards]choose one path
Merge nodediamond, many in – one outjoin alternative paths
Forkthick bar, one in – many outstart parallel (concurrent) flows
Jointhick bar, many in – one outsynchronise parallel flows
Object noderectangledata/object passed between actions
Swimlane (partition)vertical/horizontal laneswho performs the action
Signal send / receive, time eventpentagon shapes / hourglassevents
Activity final / flow finalbull’s-eye / circled Xend of all flows / end of one flow

Example – patient appointment:

(●) -> [Patient arrives] -> <registered?> --no--> [Register & generate ID] --+
                                   |yes                                         |
                                   +---------------> <merge> <------------------+
                                                       |
                                              [Issue time & number]
                                                       |
                                              ========fork========
                                              |                  |
                                     [Print slip]        [Update doctor queue]
                                              |                  |
                                              ========join========
                                                       |
                                              [Visit doctor] -> (◉)

Activity diagrams are easy for non-technical users to read, show parallelism and responsibilities, and help to find missing steps in a process.

Q6 – GoF (Gang of Four)

The Gang of Four are Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides, authors of Design Patterns: Elements of Reusable Object-Oriented Software (1994). The book catalogues 23 design patterns – proven, reusable solutions to common object-oriented design problems. Each pattern is described by its name, intent, problem, solution (class/sequence diagrams), consequences and examples.

The patterns are based on two principles: “program to an interface, not an implementation” and “favour object composition over class inheritance”. They are grouped into three categories:

CategoryPurposePatterns
Creational (5)How objects are createdSingleton, Factory Method, Abstract Factory, Builder, Prototype
Structural (7)How classes and objects are composedAdapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy
Behavioural (11)How objects interact and share responsibilityChain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, Visitor
  • Singleton – one instance with a global access point (e.g. a single database connection or hospital configuration).
  • Factory Method – subclasses decide which class to instantiate (create different Report types).
  • Adapter – converts one interface into another the client expects (use an old billing library through a new interface).
  • Observer – when one object changes, all dependents are notified (doctor and ward notified when lab result is ready).
  • Strategy – a family of interchangeable algorithms (payment by card, cash or cheque).

Benefits: reuse of expert design experience, a shared vocabulary among developers, flexible, maintainable and loosely-coupled designs. Caution: overuse adds unnecessary complexity.

Save this paper for offline studyDownload the question paper, or save the paper together with all solved answers as a PDF.
↓ Download Paper (JPG)

About Saif R

An educator and technology enthusiast passionate about empowering students through quality education and digital learning. Dedicated to making academic resources and opportunities accessible to everyone.