Cse304 Oose Lab Manual
Cse304 Oose Lab Manual
LAB
MANUAL
Course: CSE 304- Object-Oriented Software Engineering
Contents
Lab 1 & 2 – An Introduction to Object oriented Analysis and Object- Oriented Design ....... 6
Objectives ............................................................................................................................... 6
Lab Tasks .............................................................................................................................. 6
Outcomes................................................................................................................................ 6
A Road map for OOA and OOD ........................................................................................... 6
Lab 2 and 3 - Introduction and Project Definition ................................................................ 10
Objectives ............................................................................................................................ 10
Outline ................................................................................................................................. 10
Outcome .............................................................................................................................. 10
Introduction to lab plan ....................................................................................................... 10
Lab Task .............................................................................................................................. 10
Lab 3– Software Processes ................................................................................................... 12
Objectives ............................................................................................................................ 12
Lab Task .............................................................................................................................. 12
Recommended Readings ..................................................................................................... 12
Outcome .............................................................................................................................. 12
Background ......................................................................................................................... 12
Lab 4 & 5- Project Planning and Management ..................................................................... 14
Objectives ............................................................................................................................ 14
Outline ................................................................................................................................. 14
Lab Task : ............................................................................................................................ 14
Outcome .............................................................................................................................. 14
Project Work Plan ............................................................................................................... 14
Tracking Progress ................................................................................................................ 14
Risk Management ................................................................................................................ 14
CASE Tools......................................................................................................................... 15
Lab 6 and 7 - Software Requirement Specification .............................................................. 16
Objectives ............................................................................................................................ 16
Lab Task: ............................................................................................................................. 16
1 Outcome : ..................................................................................................................... 16
2. Background ..................................................................................................................... 16
2
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
3
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Outcome : .............................................................................................................................. 44
Lab Task................................................................................................................................ 44
Example - Graphic Editor ..................................................................................................... 46
Case Study 1- A Point-of-Sale (POS) system ....................................................................... 51
Project Analysis: ................................................................................................................. 51
Creating Use case Diagrams: .............................................................................................. 51
Creating Class Diagrams: .................................................................................................. 52
Creating collaboration diagrams: ........................................................................................ 53
Creating activity diagrams: ................................................................................................. 54
Case Study 2 - ONLINE BOOKSHOP ................................................................................. 54
Project Analysis: ................................................................................................................. 54
Creating use case diagrams ................................................................................................. 54
Creating class diagrams ....................................................................................................... 55
Creating collaboration diagram: .......................................................................................... 57
Creating activity diagrams: ................................................................................................. 57
Case Study 3 - An Automated Company .............................................................................. 59
Case Study 4- Multi-threaded airport automation ................................................................ 65
Design Patterns ..................................................................................................................... 71
INTRODUCTION ............................................................................................................... 71
Types of Design Pattern ...................................................................................................... 71
Lab 23 & 24 ABSTRACT FACTORY Pattern .................................................................... 72
Objective: ............................................................................................................................ 72
Lab Task .............................................................................................................................. 72
Theory: ................................................................................................................................ 72
Implementation.................................................................................................................... 72
Tools .................................................................................................................................... 74
Lab 25 – Singleton Pattern .................................................................................................... 75
Objective: ............................................................................................................................ 75
Lab Task .............................................................................................................................. 75
Theory ................................................................................................................................. 75
Tools .................................................................................................................................... 76
Lab 26-27 Decorator Pattern ................................................................................................. 77
Objective: ............................................................................................................................ 77
Lab Task .............................................................................................................................. 77
Theory ................................................................................................................................... 77
4
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Tools .................................................................................................................................... 78
Lab 27-28 Adapter Pattern .................................................................................................... 80
Objective: ............................................................................................................................ 80
Lab Task .............................................................................................................................. 80
Theory ................................................................................................................................... 80
Tools .................................................................................................................................... 82
Lab-29 & 30 Software Testing ............................................................................................. 83
Objectives ............................................................................................................................ 83
5
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Lab Tasks
You are suppose to provide precise answers of following questions after reading related
topics from recommended books and consulting material available on internet. Font size
should be Times New Roman, 12 pt, and justified text with 1.15 line spaces.
Outcomes
In this task, students will learn about: Basic c o n c e p t s o f Object oriented Design
& analysis for modelling the system.
Since, we are going to do a series of tutorials on UML diagrams and any tool for modelling
those such as Visual Paradigm and MS Visio. In this manner, we need to have a familiarity
with design approaches.
Recommended Readings
In this subject, you have been hit with a bewildering array of new terminology. Words like
"class", "instance", "method", "super class", "design", are all being thrown around with
reckless abandon. It's easy to lose your place. The purpose of this road map is to help keep
you grounded during the process of designing your object-oriented software systems.
Object-oriented program has become the dominant programming style in the software
industry over the last 10 years or so. The reason for this has to do with the growing size and
6
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Why Design?
In order to get the most out of using objects, OO programs require some kind of design work
before programming starts. You, as the programmer, are much more in the position of an
architect. Why do architects spend so much time on blueprints and models? One reason is
that the blueprint allows the architect to solve the problem in a relatively low-cost
environment before actually using brick and concrete. The final building is better: safer,
more energy-efficient, and so on, because the worst mistakes are corrected on paper, cheaply
and quickly, before a building falls on somebody's head. As a nice side effect, the precision
7
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
of the blueprint makes it a useful tool for communicating the design to the builders, saving
time in the building process.
OO probably requires more up-front design work than procedural programs because the job
of identifying the objects and figuring out how to divide the tasks among them is not really a
programming job. You really do need to have that started before you sit down to hack --
otherwise, how will you know where to start?
Similarly, time spent getting the design right before you start programming will almost
always save you time in the end. It's much, much easier to make major changes on a design,
which is after all just squiggly lines on paper, and then it is to make changes in hundreds or
thousands of lines of code.
The design process is typically split into two distinct phases: Object-Oriented Analysis
(OOA) and Object Oriented Design (OOD). Yes, I know that it is confusing to have one of
the sub-steps of the design process also called "design". However, the term is so entrenched
that it's hopeless to start creating new jargon.
We'll call these things "activities" rather than "steps" to emphasize that they don't have to be
done in any particular order -- you can switch to another activity whenever it makes sense
to do so. When you are actually doing this, you'll find that you want to go back and forth
between OOA and OOD repeatedly. Maybe you'll start at one part of your program, and do
OOA and OOD on that part before doing OOA and OOD on another part. Or maybe you'll
do a preliminary OOA, and then decide while working on the OOD that you need more
classes, so you jump back to OOA. That's great. Moving back and forth between OOA and
OOD is the best way to create a good design -- if you only go through each step once; you'll
be stuck with your first mistakes all the way through. I do think that it's important, though,
to always be clear what activity you are currently doing -- keeping a sharp distinction
between activities will make it easier for you to make design decisions without getting tied
up in knots.
In the OOA phase, the overall questions is "What?". As in, "What will my program need to
do?", "What will the classes in my program be?", and "What will each class be responsible
for?” You do not worry about implementation details in the OOA phase -- there will be
plenty of time to worry about them later, and at this point they only get in the way. The focus
here is on the real world --.what are the objects, tasks and responsibilities of the real system?
10 In the OOD phase, the overall question is "How?” As in, "How will this class handle its
responsibilities?", "How can I ensure that this class knows all the information it needs?",
"How will classes in my design communicate?” At this point, you are worried about some
8
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
implementation details, but not all -- what the attributes and methods of a class will be, but
not down to the level of whether things are integers or reals or ordered collections or
dictionaries or whatnot -- those are programming decisions
9
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Objectives
• Introduce the lab environment and tools used in the software engineering lab.
• Discuss the Project & learn how to write project definition.
Outline
• Introduction to the lab plan and objectives.
• Project definition.
Outcome
The software engineer is a key person analyzing the business, identifying opportunities for
improvement, and designing information systems to implement these ideas. It is important to
understand and develop through practice the skills needed to successfully design and
implement new software systems.
After this lab you will be able to define a project find its basic requirements , as well as
you will be able to plan the project activities using CASE Tools.
Lab Task
10
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
11
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Objectives
• Obtain a deeper understanding of software process models and software processes.
Lab Task
You are suppose to provide precisely written notes after reading related topics from
recommended books and consulting material available on internet. Font size should be
Times New Roman, 12 pt, and justified text with 1.15 line spaces.
Recommended Readings
1. The Unified Modeling Language User Guide by Booch, Rumbaugh, and Jacobson
2. Applying UML and Patterns 2nd edition by Craig Larman
3. Software Engineering 9th edition by Sommerville
4. Software Engineering A Practitioner’s Approach by Roger S. Pressman, Edition: 7th
Outcome
You will be able to choose a Process Model for your project by understanding of software
process models and software processes.
Background
IEEE defined a software process as: “a set of activities, practices and transformations that
people use to develop and maintain software and the associated products, e.g., project plans,
design documents, code, test cases and user manual”.
Following the software process will stabilize the development life cycle and make the
software more manageable and predictable. It will also reduce software development risk and
help to organize the work products that need to be produced during a software development
project. A well-managed process will produce high quality products on time and under budget.
So following a mature software process is a key determinant to the success of a software
project.
A number of software processes are available. However, no single software process works
well for every project. Each process works best in certain environments
Examples of the available software process models include: the Waterfall model (the Linear
model), the evolutionary development, the formal systems development, and reuse-based
(component-based) development. Other process models support iteration; these include: the
Incremental model, the Spiral model, and Extreme Programming.
12
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
13
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Objectives
• Gain understanding of project management.
• Learn how to prepare project plans.
• Learn about project risks.
• Learn MS Project case tool.
Outline
• Project work planning.
• Risk management.
• MS project.
• Examples.
Lab Task :
You are supposed to provide:
1) Gantt chart for your assigned Project
2) Work Breakdown Structure for the activities of your Project
Outcome
In this lab, you will understand the process of planning and controlling the development of
a system within a specified timeframe at a minimum cost with the right functionality.
Tracking Progress
• Gantt Chart:
o Bar chart format.
o Useful to monitor project status at any point in time.
• PERT Chart:
o Flowchart format.
o Illustrate task dependencies and critical path.
Risk Management
• Risk management is concerned with identifying risks and drawing up plans to minimize
their effect on a project.
• A risk is a probability that some adverse circumstance will occur.
• Project risks which affect schedule or resources.
• Product risks which affect the quality or performance of the software being developed.
• Business risks which affect the organization developing the software.
14
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
CASE Tools
• Microsoft Project is the clear market leader among desktop project management
applications.
15
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Objectives
• Gain a deeper understanding of the Software Requirement Specification phase and the
Software Requirement Specification (SRS).
• Learn how to write requirements and specifications.
Lab Task:
Choose a hypothetical system of significant complexity and write an SRS for the same.
1 Outcome :
You will gain the understanding of Software Requirement Specification phase and the
Software Requirement Specification (SRS). You will be able to write requirements and
specifications.
2. Background
requirement is a statement of a behavior or attribute that a system must possess for the
system to be acceptable to a stakeholder.
16
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
• Requirements validation: demonstrating that the requirements define the system that
the customer really wants.
• Requirements management: the process of managing changing requirements during the
requirements engineering process and system development, and identifying missing
and extra requirements.
•
2.2 Writing Requirements
Requirements always need to be correct, unambiguous, complete, consistent, and testable.
Creating specifications is important. However, you may not create specifications if:
• You are using a very incremental development process (small changes).
• You are building research or proof of concept projects.
• You rebuilding very small projects.
• It is not cheaper or faster than building the product.
17
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
• Verifiable: there exists some finite process with which a person/machine can check that
the actual as-built software product meets the requirements.
• Consistent in behavior and terms.
• Understandable by customers.
• Modifiable: changes can be made easily, completely and consistently.
• Design independent: doesn't imply specific software architecture or algorithm.
• Concise: shorter is better.
• Organized: requirements in SRS are easy to locate; related requirements are together.
• Traceable: each requirement is able to be referenced for later use (by the using
paragraph numbers, one requirement in each paragraph, or by using convention for
indication requirements)
The software to be designed will control a simulated automated teller machine (ATM) having
a magnetic stripe reader for reading an ATM card, a customer console (keyboard and
display) for interaction with the customer, a slot for depositing envelopes, a dispenser for
cash, a printer for printing customer receipts, and a key-operated switch to allow an operator
to start or stop the machine. The ATM will communicate with the bank's computer over an
appropriate communication link. (The software on the latter is not part of the requirements
for this problem.)
The ATM will service one customer at a time. A customer will be required to insert an ATM
card and enter a personal identification number (PIN) - both of which will be sent to the bank
for validation as part of each transaction. The customer will then be able to perform one or
more transactions. The card will be retained in the machine until the customer indicates that
he/she desires no further transactions, at which point it will be returned - except as noted
below.
The ATM must be able to provide the following services to the customer:
1. A customer must be able to make a cash withdrawal from any suitable account
linked to the card. Approval must be obtained from the bank before cash is dispensed.
2.A customer must be able to make a deposit to any account linked to the card,
consisting of cash and/or checks in an envelope. The customer will enter the amount
of the deposit into the ATM, subject to manual verification when the envelope is
removed from the machine by an operator. Approval must be obtained from the bank
before physically accepting the envelope.
3. A customer must be able to make a transfer of money between any two accounts
linked to the card.
4. A customer must be able to make a balance inquiry of any account linked to the
card.
A customer must be able to abort a transaction in progress by pressing the Cancel key instead
of responding to a request from the machine.
18
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
The ATM will communicate each transaction to the bank and obtain verification that it was
allowed by the bank. Ordinarily, a transaction will be considered complete by the bank once
it has been approved. In the case of a deposit, a second message will be sent to the bank
indicating that the customer has deposited the envelope. (If the customer fails to deposit the
envelope within the timeout period, or presses cancel instead, no second message will be sent
to the bank and the deposit will not be credited to the customer.)
If the bank determines that the customer's PIN is invalid, the customer will be required to
reenter the PIN before a transaction can proceed. If the customer is unable to successfully
enter the PIN after three tries, the card will be permanently retained by the machine, and the
customer will have to contact the bank to get it back.
If a transaction fails for any reason other than an invalid PIN, the ATM will display an
explanation of the problem, and will then ask the customer whether he/she wants to do
another transaction. The ATM will provide the customer with a printed receipt for each
successful transaction, showing the date, time, machine location, type of transaction,
account(s), amount, and ending and available balance(s) of the affected account ("to" account
for transfers).
The ATM will have a key-operated switch that will allow an operator to start and stop the
servicing of customers. After turning the switch to the "on" position, the operator will be
required to verify and enter the total cash on hand. The machine can only be turned off when
it is not servicing a customer. When the switch is moved to the "off" position, the machine
will shut down, so that the operator may remove deposit envelopes and reload the machine
with cash, blank receipts, etc. The ATM will also maintain an internal log of transactions to
facilitate resolving ambiguities arising from a hardware failure in the middle of a transaction.
Entries will be made in the log when the ATM is started up and shut down, for each message
sent to the Bank (along with the response back, if one is expected), for the dispensing of
cash, and for the receiving of an envelope. Log entries may contain card numbers and dollar
amounts, but for security will never contain a PIN.
19
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Objectives
• Study the benefits of visual modeling.
• Learn use case diagrams: discovering actors and discovering use cases.
• Practice use cases diagrams using Visual Paradigm.
Lab Task
Outcomes
Now you will learn how to apply the learned methods to draw use case diagrams from the
problem statement.
1. Outline
• Visual modeling.
• Introduction to UML.
• Introduction to visual modeling with UML.
• Use case diagrams: discovering actors and use cases.
2. Background
Visual Modeling is a way of thinking about problems using models organized around real-
world ideas. Models are useful for understanding problems, communicating with everyone
involved with the project (customers, domain experts, analysts, designers, etc.), modeling
enterprises, preparing documentation, and designing programs and databases
20
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
The UML is an attempt to standardize the artifacts of analysis and design: semantic models,
syntactic notation and diagrams. The first public draft (version 0.8) was introduced in October
1995. Feedback from the public and Ivar Jacobson's input were included in the next two
versions (0.9 in July 1996 and 0.91 in October 1996). Version 1.0 was presented to the Object
Management Group (OMG) for standardization in July 1997. Additional enhancements were
incorporated into the 1.1 version of UML, which was presented to the OMG in September
1997. In November 1997, the UML was adopted as the standard modeling language by the
OMG.
2.5 Actors
An actor is someone or something that must interact with the system under development
• Are NOT part of the system – they represent anyone or anything that must interact with
the system.
• Only input information to the system.
• Only receive information from the system.
• Both input to and receive information from the system.
• Represented in UML as a stickman.
21
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
• Actors: List of actors(external agents), indicating who initiates the use case.
• Purpose: Intention of the use case.
• Overview: Description.
• Type:primary / secondary.
• Post condition:If any
• It is shown as a rectangle.
• It helps to identify what is an external verse internal, and what the responsibilities of
the system are.
• The external environment is represented only by actors.
3. CASE Tools
22
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
The Visual Paradigm product family is designed to provide the software developer with a
complete set of visual modeling tools for development of robust, efficient solutions to real
business needs in the client/server, distributed enterprise and real-time systems environments.
The system is started up when the operator turns the operator switch to the "on" position.
The operator will be asked to enter the amount of money currently in the cash dispenser,
and a connection to the bank will be established. Then the servicing of customers can begin.
The system is shut down when the operator makes sure that no customer is using the
machine, and then turns the operator switch to the "off" position. The connection to the
bank will be shut down. Then the operator is free to remove deposited envelopes, replenish
cash and paper, etc.
23
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
then allowed to perform one or more transactions, choosing from a menu of possible types
of transaction in each case. After each transaction, the customer is asked whether he/she
would like to perform another. When the customer is through performing transactions, the
card is ejected from the machine and the session ends. If a transaction is aborted due to too
many invalid PIN entries, the session is also aborted, with the card being retained in the
machine.
The customer may abort the session by pressing the Cancel key when entering a PIN or
choosing a transaction type.
24
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
the envelope has been received, a second message is sent to the bank, to confirm that the
bank can credit the customer's account - contingent on manual verification of the deposit
envelope contents by an operator later. (The receipt of an envelope is also recorded in the
ATM's log.)
A deposit transaction can be cancelled by the customer pressing the Cancel key any time
prior to inserting the envelope containing the deposit. The transaction is automatically
cancelled if the customer fails to insert the envelope containing the deposit within a
reasonable period of time after being asked to do so.
A transfer transaction can be cancelled by the customer pressing the Cancel key any time
prior to entering a dollar amount.
An inquiry transaction asks the customer to choose a type of account to inquire about from
a menu of possible accounts. No further action is required once the transaction is approved
by the bank before printing the receipt.
An inquiry transaction can be cancelled by the customer pressing the Cancel key any time
prior to choosing the account to inquire about.
5. Exercises
Read carefully the following problem statement
We are after a system that controls a recycling machine for returnable bottles and cans. The
machine will allow a customer to return bottles or cans on the same occasion. When the
customer returns an item, the system will check what type has been returned. The system will
register how many items each customer returns and, when the customer asks for a receipt, the
25
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
system will print out what he deposited, the value of the returned items and the total return sum
that will be paid to the customer. The system is also be used by an operator. The operator wants
to know how many items of each type have been returned during the day. At the end of the
day, the operator asks for a printout of the total number of items that have been deposited in
the machine on that particular day. The operator should also be able to change information in
the system, such as the deposit values of the items. If something is amiss, for example if a can
gets stuck or if the receipt roll is finished, the operator will be called by a special alarm signal.
After reading the above problem statement, find:
1. Actors
2. Use cases with each actor
3. Find extend or include use cases (if applicable)
4. Finally: draw the main use case diagram
26
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Objective:
Deeper understanding of System modeling:
• Data model: entity-relationship diagram (ERD).
• Functional model: data flow diagram (DFD).
Lab Tasks:
You are required to provide the following:
• Data model: entity-relationship diagram (ERD) of your assigned project.
• Functional model: data flow diagram (DFD) of your assigned project.
Outcomes
After this lab you will be able to produce data model and the functional model of any
software system
System Modeling
2. Background
Modeling consists of building an abstraction of reality. These abstractions are
simplifications because they ignore irrelevant details and they only represent the relevant
details (what is relevant or irrelevant depends on the purpose of the model).
A wide variety of models have been in use within various engineering disciplines for a long
time. In software engineering a number of modeling methods are also available.
27
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Entity
Relationship
External entity
Process
Data flow
Control flow
Data store
28
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
• CASE Tools
You can use MS Visio or Visual Paradigm to create your ERD and DFD
29
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Objectives
Study how to document use cases in detail.
• Know about scenarios (flow of events) and its importance.
• Deeper understanding of UML activity diagrams.
• Practicing flow of events and activity diagrams using visual paradigm
Outcome :
In this lab you will study how to document use cases in detail. Then you will know about
scenarios (flow of events) and its importance with deeper understanding of UML activity
diagrams.This will help you to Practice flow of events and activity diagrams using visual
paradigm
Lab Task
You are required to produce the following
• Use cases of your system with its descriptions
• Activity diagrams of your system
1. Outline
• Writing flow of events.
• Flow of events template and example.
• Activity diagrams.
• Examples.
2. Background
Each use case is documented with a flow of events. The flow of events for a use case is a
description of the events needed to accomplish the required behavior of the use case.
Activity diagrams may also be created at this stage in the life cycle. These diagrams
represent the dynamics of the system. They are flow charts that are used to show the workflow
of a system; that is, they show the flow of control from one activity to another in the system,
30
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Use case ID: 001 Use case Name: <<type name of use case >>
Priority:
Actors:
Pre-condition:
1.
2.
Post Conditions
Includes
Extends
A sample completed flow of events document for the Select Courses to Teach use case follows.
31
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
1.1 Preconditions
Create course offerings sub-flow of the maintain course information use case must
execute before this use case begins.
If the activity selected is ADD, the S-1: add a course offering sub-flow is performed.
If the activity selected is DELETE, the S-2: delete a course offering sub-flow is performed.
If the activity selected is REVIEW, the S-3: review schedule sub-flow is performed.
If the activity selected is PRINT, the S-4: print a schedule sub-flow is performed.
1.3 Sub-flows
S-1: Add a Course Offering:
The system displays the course screen containing a field for a course name and number.
The professor enters the name and number of a course (E-3). The system displays the course
offerings for the entered course (E-4). The professor selects a course offering. The system links
the professor to the selected course offering (E-5). The use case then begins again.
32
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
• E-1: An invalid professor ID number is entered. The user can re-enter a professor ID
number or terminate the use case.
• E-2: An invalid semester is entered. The user can re-enter the semester or terminate the use
case.
• E-3: An invalid course name/number is entered. The user can re-enter a valid name/number
combination or terminate the use case.
• E-4: Course offerings cannot be displayed. The user is informed that this option is not
available at the current time. The use case begins again.
• E-5: A link between the professor and the course offering cannot be created. The
information is saved and the system will create the link at a later time. The use case
continues.
• E-6: An invalid course offering name/number is entered. The user can re-enter a valid
course offering name/number combination or terminate the use case.
• E-7: A link between the professor and the course offering cannot be removed. The
information is saved and the system will remove the link at a later time. The use case
continues.
• E-8: The system cannot retrieve schedule information. The use case then begins again.
• E-9: The schedule cannot be printed. The user is informed that this option is not available
at the current time. The use case begins again.
Use case flow of events documents are entered and maintained in documents external to
Rational Rose. The documents are linked to the use case.
3. CASE Tools
MS Visio / Visual Paradigm
33
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Objective
Learn the object-oriented analysis phase by understanding the methods of class elicitation
and finding the classes in an object-oriented system.
Outcome :
In this lab you will study the object-oriented analysis phase, You will be able to understand
the methods of class elicitation and find the classes in an object-oriented system.
Lab Task
You are required to find the appropriate classes for your system, with proper naming
according to the Naming Conventions
1. Outline
• Object-Oriented concepts
• Discovering classes’ approaches: noun phrase approach, common class patterns, use
case driven method, CRC (Class-Responsibility-Collaboration) and mixed approach.
• Examples.
2. Background
Classes: a description of a group of objects with common properties (attributes), common
behavior (operations), common relationships to other objects and common semantics.
34
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
• An abstract class is a class that has no direct instance but whose descendant’s
classes have direct instances.
• An abstract class can define the protocol for an operation without supplying a
corresponding method we call this as an abstract operation.
• An abstract operation defines the form of operation, for which each concrete subclass
should provide its own implementation.
2.4.1 Noun Phrase Approach: Examine the requirements and underline each noun. Each
noun is a candidate class; divide the list of candidate classes into:
• Relevant classes: part of the application domain; occur frequently in requirements.
• Irrelevant classes: outside of application domain
• Fuzzy classes: unable to be declared relevant with confidence; require additional
analysis
2.4.2 Common Class Patterns: Derives candidate classes from the classification theory of
objects; candidate classes and objects come from one of the following sources:
• Tangible things: e.g. buildings, cars.
• Roles: e.g. teachers, students.
• Events: things that happen at a given date and time, or as steps in an ordered
sequence: e.g. landing, request, interrupt.
• Interactions: e.g. meeting, discussion.
• Sources, facilities: e.g. departments.
• Other systems: external systems with which the application interacts.
• Concept class: a notion shared by a large community.
• Organization class: a collection or group within the domain.
• People class: roles people can play.
• Places class: a physical location relevant to the system.
2.4.3 Use Case Driven Method: The scenarios - use cases that are fundamental to the
system operation are enumerated. Going over each scenario leads to the identification
of the objects, the responsibilities of each object, and how these objects collaborate
with other objects.
35
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
2.4.5 Mixed Approach: A mix of these approaches can be used, one possible scenario is:
• Use CRC for brainstorming.
• Identify the initial classes by domain knowledge.
• Use common class patterns approach to guide the identification of the classes.
• Use noun phrase approach to add more classes.
• Use the use case approach to verify the identified classes.
3. CASE Tools
Visual Paradigm
36
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Outcome :
In this lab you will study how to document interaction diagrams in detail. Then you will
know about scenarios (flow of events) and its importance with deeper understanding of UML
sequence diagrams and collaboration diagrams. This will help you to Practice flow of
interaction in these diagrams using visual paradigm
Lab Task
You are required to produce the following
• Sequence diagrams of your system with its descriptions
• Collaboration/Communication diagrams of your system by transforming the
sequence diagram into collaboration diagrams
1. Outline
• Interaction diagrams:
o Sequence diagrams
o Collaboration diagrams
2. Background
Interaction diagrams describe how groups of objects collaborate in some behavior. An
interaction diagram typically captures the behavior of a single use case.
Interaction diagrams do not capture the complete behavior, only typical scenarios.
37
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
2.5 Notes
• Always keep your diagrams simple.
• For “IF... then ...” else scenarios, you may draw separate sequence diagrams for the
different branches of the “if statement”. You may even hide them, (at least during the
analysis phase) and document them by the text description accompanying the sequence
diagrams.
3. CASE Tools
Rational Rose (introduced in lab 5).
38
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Objectives
• Deeper understanding of software design and the software design document (SDD).
Learn how to find the relationships between classes to create UML class diagram.
Outcome:
In this lab you will study how to document software design diagrams in detail. Then you will
know about relationship of classes and its importance with deeper understanding of UML
class diagrams.
Lab Task
You are required to produce the following
• Class diagram of your system with its descriptions
• Documenting the Class Diagram in SDD
1. Outline
• Software design concepts and principals.
• Software architecture.
• Specifying the attributes and the operations and finding the relationships between
classes.
• Creating UML class diagram.
• Software design document.
2. Background
The purpose of software design is “to produce a workable (implementable) solution to a
given problem.” David Budgen in Software Design: An Introduction.
39
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
3. CASE Tools
Visual Paradigm.
40
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Outcome :
In this lab you will study how to document state chart diagrams in detail. Then you will know
about states with transitions and its importance with deeper understanding of UML state
machine diagrams. This will help you to Practice transitions of state in the diagram using
visual paradigm
Lab Task
You are required to produce the state chart diagrams with proper transition of states of your
assigned project
1. Outline
• UML state diagrams.
• UML state diagram notation
• UML state details
• Examples
2. Background
Mainly, we use interaction diagrams to study and model the behavior of objects in our
system. Sometimes, we need to study the behavior of a specific object that shows complex
behavior to better understand its dynamics. For that sake, UML provides state transition
diagrams used to model the behavior of objects of complex behavior. In this Lab, UML state
transition diagrams will be introduced. We will study their notation and how can we model
them using Rational Rose.
41
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
42
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
3. CASE Tools
Visual Paradigm and MS Visio
43
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Objectives
• Become familiar with the implementation diagrams: component and deployment
diagrams.
• Practice using Visual Paradigm.
Outcome :
In this lab you will study how to document implementation diagrams in detail. Then you will
know about physical structure of software systems and its importance with deeper
understanding of UML component and deployment diagrams. This will help you to practice
physical implementation of software system through diagrams using visual paradigm
Lab Task
You are required to produce the following
• Component Diagram of your system with its descriptions
• Deployment Diagram of your system by transforming the sequence diagram into
collaboration diagrams
1. Outline
• Implementation diagrams: component and deployment diagrams.
• Examples.
2. Background
Implementation diagrams capture design information. The main implementation
diagrams in UML are: component and deployment diagrams. In this Lab we will study these
diagrams and their notation.
44
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
o Packages.
o Subprograms.
o Tasks.
o Dependencies.
3. CASE Tools
Visual Paradigm and MS Visio
45
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Requirements Statement :
It is required to develop a graphics editor software package to create line drawings involving
several types of graphics entities. It should support following functionalities:
• It contains the toolbox which contains tools like: Line, Circle, Rectangle, Arc, Polygon,
Parallelogram, Text, Draw, Eraser
• Color box or palette
• Standard toolbar with options for New, Open, Save, toolbox and Text Toolbox.
• One integrated view to users for toolbar, color box, menu, and graphic screen. • Easy
handling of tools for users.
• Ability to group several drawing into one i.e. complex drawing.
• Provision of zoom in and zoom out.
• Different shadings of line tool are provided.
46
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
47
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
48
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
49
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
50
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
A POS system is a computerized application used to record sales and handle payments; it
is typically used in retail store. It includes hardware components such as a computer and bar
code scanner , and software to run to run the system. It interfaces to various applications, such
as third party tax calculator and inventory control. These systems must be relatively fault
tolerant; that is ,even if remote services are temporarily unavailable they must still be of
capturing sales and handling at least cash payments . A POS system must support multiple and
varied client-side terminals and interfaces such as browser, PDAs, touch-screens.
Identifying actors:
1. Sell items
2. Pay salaries
3. Maintenance
4. Issue bills
5. Take salary
6. Select items
7. Buy items
8. Give loans
9. Collect loans
10. Display
11. Sales
12. Profit
13. Loss
14. Pay money
Identifying relationships:
Association:
51
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
1. Supermarket
2. Customer
3. Cash payment
4. Staff
5. Items
6. Bank
7. Sales
8. Cashier
9. Profit
10. Loss
11. Billing system
12. hardware
13. software
14. scanner
15. Barcode reader
16. Determine tax
17. Stationary
Aggregation:
Association:
Generalization:
hardware
Dependency:
1. Profit is dependent on sales
2. Loss is dependent on sales
52
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Identifying attributes:
Identifying operations
1.Supermaket:sell items
2.Customer:buy items
3.Cash patment:display
4.Staff:Worktimings:salary
5.Items:display
6.Sales:Display
7.Cashier:Collect cash
8.profit:display
9.loss:display
10.billing system:issuable,display
11.hardware
12.software
13.scanner:scam code
14.barcode reader:barcodescan
15.determine tax;display
16.staionary:display
Identifying objects:
1.s.supermarket
2.cp.cash payment
3.st.staff
4.i.items5.b.bank
6.sl.sales
7.cs.cashier
8.bs.billing systems
9.br.barcode reader
53
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Identifying messages:
1.Supermarket exhibit items to customer
2.Supermarket gives item details to customers
3.customer enters to super market
4.pos check password of customer
5.customer selects item
6.staff guide customer
7.Barcode scanner identify product of super market
8.Super market produces the billing from
9.Cashier verifies the account of customer
10.customer pay bill system
11.Cashier give product to customer
Identifying activities:
Online book shop is an application used to maintain information about the items that are
generally available in that book shop. Any customer can access the information about the item
and he can also order item through online by creating his login in that site. Customer can change
the already entered details. The items information in that site is entered by the bookshop staff
and it can be change if there are any modifications.
The following needs must be addressed by the system for actors are:
1 Customers to order books, access the details of the books and to receive books.
2 Bookshop staff provides the details of books and to send the books.
1 Costumer
2 Bookshop staff
The following needs must be addressed by the system for use cases are:
1 Customer registers the details of the books that are required and his personal details.
2 Customer browses the site of bookshop and selects the required books and orders.
3 The books that ordered by the customers are delivered to the appropriate customers.
54
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
4 If customer wants to change his details that are registered then it is possible through
customer update details.
5 If any new items enter the book shop or any items that removed are entered by
the bookshop details.
The following needs must be addressed by the system for classes are:
1 Book
2 Item
3 Customer
1 Bookshop staff
2 Music cd
3 Software
4 Book
5 Address
For each class attributes, relationships must be made.
For example the book attributes are book name, book id, author name etc.
Inheritance:
1 Book is an item
2 Music cd is an item
3 Software is an item
4 Billing address is an address
5 Shipping address is an address
Aggregation:
Association:
Dependency:
Identify attributes:
Welcome message
Login and password
Error message
Browse and order
Show order and cost
Book:
Display
Music cd:
Display
Software:
Display
Shopping cart:
Additem
Display
Itemorder
Order:
Computeitemstotal
Printinvoice
56
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Display
Itemorder
Customer:
Verifypassward
Additemtoshoppingcart
Creat order
Printbillinglable
Printshppinglable
Address:
Billingaddress:
Shippingadrress:
Identifying objects:
1. B.Bookshop
2. Bs.Bookshop staff
3. O.Order
4. C.Customer
5. a.Address
6. sc.Shopping
Identifying messages:
The following needs must be the addresses by the systems for the activities are:
1. When the custom opens the site then welcome message must be displayed.
57
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
2. If the customer wants to order books then he creates the login name and password.
3. Authentication is done after the customer login.
4. Customer can login the desired books.
5. The ordered books are transferred to the appropriate customers.
Activities identified are:
2. Customer login
4. Customer browses.
8. Customer done
58
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Automate a small manufacturing company. The resulting application will enable the
user to take out a loan, purchase a machine, and over a series of monthly production runs,
follow the performance of their company.
Creating use case diagram:
Identifying actors
1. Recruit employee
2. Give salary
3. Pay for raw materials
4. Maintain machines
5. Dismiss employee
6. Product goods
7. Work
8. Maintain union
9. Take salary
10. Give loan
11. Collect interest
12. Collect loan
13. Bye goods
14. Pay money
Identifying relationships
Generalization
1. Technical staff is a type of employee
2. Non technical staff is a type of
employee Association
1.Company recruits employee
59
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
12.Customer pays
Identifying classes:
1.Company
2.Bank
3.Employees
4.Technical
5.Non technical
6.Customers
7.Shares
8.Machines
9.Goods
10.Customer
11.Market
12.Sales
13.Status
14.Profit
15.Loss
16.Rawmaterials
17.Department
Inheritance:
1.status contains profit
Aggregation:
Association:
Dependency:
Identifying attributes:
1.company:name,code,address
2.bank:name,address,branchname
3.employee:department,hrswork
4.technical:name,id,hourswork
5.nontechnical:name,id,hourswork
6.shares:code
7.machines:type,cost,size,capacity
8.goods:name,code
9.customer:name
10.market:name,address
13.profit
14.loss
Company:
1.check attendance
2.give salary
61
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
4.maintained machines
6.recruit employee
7.dismiss employee
Customer:
1.buy goods
2.pay money
Bank:
1.give loan
2.collect interest
3.collect loan
Employee:
1.work
2.take salary
3.maintain union
Non technical:
1.work
2.take salary
3.maintain union
Shares
1.increase on profit
2.decrease on loss
machines
market
1.receive goods
2.sell goods
sales
1.calculate status
Status
profit
2.calculate status
3.profit amount
loss
2.calculate status
3.loss amount
Identifying objects
1.c:company
2.s:shares
3.r:raw materials
4.m:machinery
5.sa:sales
6.c:customer
7. m:market
8.g:goods
9.e:employee
10.b:bank
Identifying messages
63
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Identification of activities:
64
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
1. check luggage
2. give ticket
3. ticket booking
4. take money
5. maintainance
6. give salary
7. take off
8. land off
9. visa check
11. timings
13. management
Identifying relationships:
Genenaralization:
Association:
65
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Include
Extend
1 .after ticket booking the air plane may or may not come in time
Identifying classes:
1. Airport
2. Location management
3. Staff
4. Security
5. Technical staff
7. Customer
8. Visa check
9. Ticket booking
11. aeroplane
12.local planes
13.international planes
15. bakery
16. stationary
19. Pilots
66
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
20. Helpdesk
Aggregation:
Generalization:
Dependency:
Identifying attributes:
5.security: name,id,type
8.customs:name,id
9.visacheck:name,id
67
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
11.onlinebooking:name,code,destination
18.pilots:name, id
19.helpdesk:name, id
airport
take off
landing
parking of planes
management
gives salary
maintenance
control staff
staff
work
take salary
customs
check luggage
check persons
visa check
visa check
ticket booking
book ticket
give ticket
Take money
Aeroplanes
68
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Reach destination
Takeoff
Buy goods
Bakery
Pay to management
Stationary
Pay to management
Electronic
Pay to management
Restaurant
Pay to management
Pilots
Helpdesk
Tell details
Identifying objects:
1.P:Passenger
2.T:ticket booking
3.St:timings
4.Aa:aeroplanes
5.T:timings
6.A:airport
7.S:shoppingstalls
Identifying messages:
Identification of activities;
1.passenger enters
2. Check visa.
3. Grant permission
4.Send out
6.pay money
7.Don’t pay
9.inform arrival
10.Boarding of passenger
12.reach destination.
70
Downloaded by Suvetha.S ([email protected])
CSE304–OOSE Lab Manual
lOMoARcPSD|35019703
Design Patterns
INTRODUCTION
Design patterns represent the best practices used by experienced object-oriented
software developers. Design patterns are solutions to general problems that
software developers faced during software development. These solutions were
obtained by trial and error by numerous software developers over quite a substantial
period of time.
Objective:
Implement Abstract Factory Pattern using Java
Lab Task
Implement the Abstract Factory Pattern using Java according to the instructions given
in the theory section. You are also supposed to draw class diagram using CASE tools.
Theory:
Abstract Factory patterns works around a super-factory which creates other factories.
This factory is also called as Factory of factories. This type of design pattern comes
under creational pattern as this pattern provides one of the best ways to create an
object. In Abstract Factory pattern an interface is responsible for creating a factory of
related objects,without explicitly specifying their classes. Each generated factory can
give the objects as per the Factory pattern.
Implementation
We're going to create a Shape and Color interfaces and concrete classes
implementing these interfaces. We creates an abstract factory class AbstractFactory
as next step. Factory classesShapeFactory and ColorFactory are defined where
each factory extends AbstractFactory. A factory creator/generator class
FactoryProducer is created.
Steps
Use the following steps to implement the above mentioned design pattern.
Step 1
Create an interface for Shapes.
Shape.java
Step 2
Create concrete classes implementing the same interface.
Rectangle.java
Square.java
Step 3
Create an interface for Colors.
Color.java
Step4
Green.java
Blue.java
Step 5
Create an Abstract class to get factories for Color and Shape Objects.
AbstractFactory.java
Step 6
Create Factory classes extending AbstractFactory to generate object of concrete
class based on
given information.
ShapeFactory.java
ColorFactory.java
}
Step 7
Create a Factory generator/producer class to get factories by passing an
information such as Shape or Color
FactoryProducer.java
Step 8
Use the FactoryProducer to get AbstractFactory in order to get factories of
concrete classes by
passing information such as type.
AbstractFactoryPatternDemo.java
Class Diagram
Step 9
Tools
NetBeans
MS Visio/ Visual Paradigm
Lab Task
Implement the Singleton Pattern using Java according to the instructions given in the
theory section. You are also supposed to draw class diagram using CASE tools.
Theory
Singleton pattern is one of the simplest design patterns in Java. This type of design
pattern comes under creational pattern as this pattern provides one of the best way
to create an object. This pattern involves a single class which is responsible to
creates own object while making sure that only single object get created. This class
provides a way to access its only object which can be accessed directly without
need to instantiate the object of the class.
Implementation
We're going to create a SingleObject class. SingleObject class have its constructor
as private and have a static instance of itself.SingleObject class provides a static
method to get its static instance to outside
world.SingletonPatternDemo, our demo class will use SingleObject class to geta
SingleObject object.
Class Diagram
Steps
Use the following steps to implement the above mentioned design pattern.
Step 1
Create a Singleton Class.
SingleObject.java
Step 2
Get the only object from the singleton class.
SingletonPatternDemo.java
Step 3
Verify the output.
Hello World!
Tools
NetBeans
MS Visio/ Visual Paradigm
Objective:
Implement Decorator Pattern using Java
Lab Task
Implement the Decorator Pattern using Java according to the instructions given in the
theory section. You are also supposed to draw class diagram using CASE tools.
Theory
Decorator pattern allows adding new functionality an existing object without
altering its structure. This type of design pattern comes under structural pattern as
this pattern acts as a wrapper to existing class. This pattern creates a decorator class
which wraps the original class and provides additionalfunctionality keeping class
methods signature intact.
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.
Steps
Use the following steps to implement the above mentioned design pattern.
Step 1
Create an interface.
Shape.java
Step 2
Create concrete classes implementing the same interface.
Rectangle.java
Step 3
Step 4
Step 5
Use the RedShapeDecorator to decorate Shape objects.
DecoratorPatternDemo.java
Class Diagram
Step 6
Verify the output.
Circle with normal border
Shape: Circle
• NetBeans
• MS Visio/ Visual Paradigm
Objective:
Implement Adapter Pattern using Java
Lab Task
Implement the Adapter Pattern using Java according to the instructions given in the
theory section. You are also supposed to draw class diagram using CASE tools.
Theory
Adapter pattern works as a bridge between two incompatible interfaces. This type
of design pattern comes under structural pattern as this pattern combines the
capability of two independent interfaces. This pattern involves a single class which
is responsible to join functionalities of independent or incompatible interfaces.
A real life example could be a case of card reader which acts as an adapter between
memory card and a laptop. You plugins the memory card into card reader and card
reader into the laptop so that memory card can be read via laptop. We are
demonstrating use of Adapter pattern via following example in which an audio
player device can play mp3 files only and wants to use an advanced audio player
capable of playing vlc and mp4 files.
Implementation
We want to make AudioPlayer to play other formats as well. To attain this, we've
created an adapter class MediaAdapter which implements the MediaPlayer
interface and uses AdvancedMediaPlayerobjects to play the required
format.AudioPlayer uses the adapter class MediaAdapter passing it the desired
audio type without knowing the actual class which can play the desired format.
AdapterPatternDemo, our demo class will useAudioPlayer class to play various
formats.
Steps
Use the following steps to implement the above mentioned design pattern.
Step 1
Create interfaces for Media Player and Advanced Media Player.
MediaPlayer.java
Step 2
VlcPlayer.java Mp4Player.java
Step 3
MediaAdapter.java
Step 4
Create concrete class implementing the MediaPlayer interface.
AudioPlayer.java
Step 5
Use the AudioPlayer to play different types of audio formats.
AdapterPatternDemo.java
Class Diagram
Step 6
Verify the output.
Playing mp3 file. Name: beyond the horizon.mp3
Tools
• NetBeans
• MS Visio/ Visual Paradigm
Objectives
• Gain a deeper understanding of software testing and the software testing
document.
• Become familiar with a software testing tool (JUnit).
1. Outline
• Overview of software testing.
• Unit testing.
• JUnit tutorial.
• Software test specification.
2. Background
Testing is the process of executing a program with the intent of finding errors. A
good test case is one with a high probability of finding an as-yet undiscovered error. A
successful test is one that discovers an as-yet-undiscovered error.
The causes of the software defects are: specification may be wrong; specification may
be a physical impossibility; faulty program design; or the program may be incorrect.
3. CASE Tools
JUnit is an open-source project to provide a better solution for unit testing in Java.
It can be integrated with many Java IDEs.
Central idea: create a separate Java testing class for each class you’re creating, and then
provide a means to easily integrate the testing class with the tested class for unit testing.