SRE Lab 02
SRE Lab 02
LAB 02
Introduction to UML
OBJECTIVES:
The UML consists of a number of graphical elements that combine to form diagrams.
UML is a language; it has rules for combining these elements.
The purpose of the diagrams is to present multiple views of a system; this set of multiple
views is called a model.
A UML model tells what a system is supposed to do.
UML can be used with all processes, throughout the software development life cycle. UML is not
a methodology, it does not require any formal work products .Yet it does provide several types of
diagrams that increase the ease of understanding an application under development.
The most useful, standard UML diagrams are:
Software Requirement Engineering 2nd Semester-SE UET Taxila
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
Person
Attributes: height, weight, and age.
Each of us is unique because of the specific values that each of us has for those attributes.
We also perform these operations: eat, sleep, read, write, talk, go to work, and more.
If we were to create a system that deals with information on people—say, a system for a human
resources department—we would likely incorporate some of these attributes and some of these
operations in our software.
Washing Machine
Class:
In the world of object-orientation, a class is used for categorization.it is used to place all same
types of things under a single name. For example students together makes a class because they
have same education level, same subjects and they do same operation that is takeclass() etc.
A class is also a template for making objects sort of like a cookie cutter that you use to stamp out
cookies.
Object:
An object is an instance of a class (a category). You and I, for example, are instances of the
Person class. An object has structure. That is, it has attributes (properties) and behavior. An
object's behavior consists of the operations it carries out. You can create new objects based on
WashingMachine class. In a class students are objects of class. For example you all are objects of
2k12-SE class.
Task 1:
Patient, software department, mobile phone, school, bus, Rawalpindi express
a. Identify the classes and objects from the list given above.
b. Write at least 3 attributes and 2 operations of each class found in above list.
c. Name the possible class of objects you found in above list.
Object-orientation goes beyond just modeling attributes and behavior. It considers other aspects
of objects as well.
Abstraction
Abstraction means, simply, to filter out an object's properties and operations until just the ones
you need are left. What does "just the ones you need” means?
Different types of problems require different amounts of information, even if those problems are
in the same general area. In the second pass at building a washing machine class, more attributes
and operations emerged than in the first pass. Was it worth it?
If you're part of a development team that's ultimately going to create a computer program that
shows exactly how a washing machine does washing. A computer program like that has to have
enough in it to make accurate predictions about what will happen when the washing machine is
built, fully functioning, and washing clothes.
For this kind of program, in fact, you can filter out the serial Number attribute because it's
probably not going to be very helpful.
What if, on the other hand, you're going to create software to track the transactions in a laundry
that has a number of washing machines? In this program you probably won't need all the detailed
attributes and operations mentioned in the preceding section. You might, however, want to
include the serialNumberof each washing machine object.
In any case, what you're left with, after you've made your decisions about what to include and
what to exclude, is an abstraction of a washing machine.
Task 2:
First name, last name ,father name , date of birth, home address, matric marks ,intermediate
marks , college name, postal address, age, mother name, eyesight number, user name, email
id ,Facebook id, password, confirm password, security question ,security code, terms and
conditions.
a. From the above list write down the information that you will need to sign up in a
yahoo account.
b. From the list of information you gathered for signup in yahoo account abstract
the information that you will require to login to yahoo account.
Task 3:
Inheritance
Washing machines dishwashers,
refrigerators, radios,
microwave ovens, blenders,
toasters, irons
What you say what are all these? These are all appliances. In the world of
object orientation, we would say that each one is a subclass of the Appliance
class. Another way to say this is that Appliances a super class of all those
others.
Appliances a class that has the attributes on Off Switch and electricWire, and
the operations turnOn() and turnOff(). Thus, if you know something is an
appliance, you know immediately that it has the Appliance class's attributes
and operations.
It's important to note that each subclass adds its own attributes and operations.
Figure 2.3 shows the superclass-subclass relationship.
Figure 2.4. Super classes can also be subclasses and inherit from other super
classes.
Task 4:
Car, Student, tree, mango tree, Patient, Person, BMW, things, Honda,
human, City, Vehicle, non-living things, bike, bicycle,animal,
Polymorphism
Sometimes an operation has the same name in different classes. For example,
you can open a door, you can open a window, and you can open a newspaper,
a present, a bank account, or a conversation. In each case you're performing a
different operation. In object-orientation each class "knows" how that
operation is supposed to take place. This is called polymorphism.
Encapsulation
In a TV commercial, two people discuss all the money they'll save if they dial
a particular seven-digit prefix before dialing a long-distance phone call.
One of them asks, incredulously, "How does that work?" The other replies:
"How does popcorn pop? Who cares?"
That's the essence of encapsulation: When an object carries out its operations,
those operations are hidden. When most people watch a television show, they
usually don't know or care about the complex electronics components that sit
in back of the TV screen and all the many operations that have to occur in
order to paint the image on the screen. The TV does what it does and hides the
process from us. Most other appliances work same way.
Interface:
Because encapsulation means that an object hides what it does from other
objects and from the outside world, encapsulation is also called information
hiding. But an object does have to present a "face" to the outside world so you
can initiate those operations. The TV, for example, has a set of buttons either
on the TV itself or on a remote. A washing machine has a set of dials that
enable you to set temperature and water level. The TV's buttons and the
washing machine's dials are called interfaces.
What is StarUML?
StarUML™ is a software modeling platform that supports UML (Unified
Modeling Language).
Installation Steps: Run the setup.
Step 1:
Step 2
Step 3
Step 4
Step 5
Step 6
StarUML Environment