Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of...

127
Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava [email protected] http://vondrak.cs.vsb.cz

Transcript of Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of...

Page 1: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Software Engineering

Prof. Ing. Ivo Vondrak, CSc.Dept. of Computer Science

Technical University of [email protected]

http://vondrak.cs.vsb.cz

Page 2: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Motto:A physician a civil engineer, and a computer scientist were arguing about what was the oldest profession in the world. The physician remarked, "Well, in the Bible, it says that God created Eve from rib taken out of Adam. This clearly required surgery, and so I can rightly claim that mine is the oldest profession in the world. " The civil engineer interrupt, and said, "But even earlier in the book of Genesis, it states that God created the order of heavens and earth from out of chaos. This was the first and certainly the most spectacular application of civil engineering. Therefore, fair doctor, you are wrong: mine is the oldest profession in the world." The computer scientist leaned back in the chair, smiled, and then said confidently, "Ah, but who do you think created the chaos?"

Page 3: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

References Humphrey, W. Managing the Software Process, Addison-Wesley/SEI

series in Software Engineering, Reading, Ma, 1989 Gamma, E., Helm,R., Johnson,R., Vlissides,J. Design Patterns, Elements

of Reusable Object-Oriented Software, Addison-Wesley, 1994 Icon Computing, Inc. Object-Oriented Design, Idioms and Architectures,

Austin, 1996 Rational Unified Process Whitepaper: Best Practices for Software

Development Teams - Rational Software, 1998 Jacobson, I., Booch, G., Rumbaugh, J.: The Unified Software

Development Process, Addison Wesley Longman, Inc., 1999 Booch, G., Jacobson, I., Rumbaugh, J.: The Unified Modeling Language

User Guide, Addison Wesley Longman, Inc., 1999 Schmuller, J.: Teaching Yourself UML in 24 Hours, Sams, 1999

Page 4: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Definition of Software Engineering

Software engineering involves: technical and non-technical issues knowledge of specification, design and implementation

techniques human factors software management

Software engineering is an engineering disciplineconcerned with practical problems of developing largesoftware systems.

Software engineering is an engineering disciplineconcerned with practical problems of developing largesoftware systems.

Page 5: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Software Production Layout

Software ProcessSoftware Process

instantiated by ProjectProject

ProjectProject

ProjectProject

Project Management• Planning• Control

Project Management• Planning• Control

Project Execution• Analysis• Design• Implementation• Test

Project Execution• Analysis• Design• Implementation• Test

consists of consists of

ProjectManagementMethodology

ProjectManagementMethodology Software

DevelopmentMethodology

SoftwareDevelopmentMethodology

usesuses

System ofmethods forprojectmanagement

System ofmethods forsoftware productdevelopment

is a is a

Page 6: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

A Definition of Process

Relationships of all tasks (workflow)

Tools Skills, Training,

Motivation, &Management

PROCESS

AB

CD

W. Humphrey and P. Feiler: "A process is a set of partially ordered steps intended to reach a goal..."(to produce and maintain requested software deliverables). A software process includes sets of related artifacts, human and computerized resources, organizational structures and constraints.

W. Humphrey and P. Feiler: "A process is a set of partially ordered steps intended to reach a goal..."(to produce and maintain requested software deliverables). A software process includes sets of related artifacts, human and computerized resources, organizational structures and constraints.

Page 7: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Initial (1)

Repeatable (2)

Defined (3)

Managed (4)

Optimizing (5)

Basic management control

Integrated end-to-end process

Measurement

Feedback

Process discipline

Process definition

Process control

Process improvement

Maturity Levels

Page 8: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Visibility Into the SW Process

In Out

In Out

In Out

In Out

In Out

1

2

3

4

5

Page 9: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

The Waterfall Process Model

Requirementsanalysis anddefinition

System andSW design

Implementation (Coding)

Testing andMaintenance

Page 10: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

The Waterfall Model: Problems

It takes too long to see results: nothing is executable or demonstrable until code is produced.

It depends on stable, correct requirements. It delays the detection of errors until the end. It does not promote software reuse. It does not promote prototyping. ...

Page 11: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Exploratory Programming

Developoutline

specification

Build softwaresystem

Use softwaresystem

Systemadequate?

Deliversoftware system

NO

YES

Page 12: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Rational Unified Process®

Best Practices: Develop software iteratively Manage requirements Use component-based architectures Visually model software Verify software quality Control changes to software

The Rational Unified Process® is a Software Engineering Process. It provides a disciplined approach to assigning tasks and responsibilities within a development organization. Its goal is to ensure the production of high-quality software that meets the needs of its end-users, within a predictable schedule and budget.

The Rational Unified Process® is a Software Engineering Process. It provides a disciplined approach to assigning tasks and responsibilities within a development organization. Its goal is to ensure the production of high-quality software that meets the needs of its end-users, within a predictable schedule and budget.

Page 13: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Develop Software Iteratively

Given today’s sophisticated software systems, it is not possible to sequentially first define the entire problem, design the entire solution, build the software and then test the product at the end.

An iterative approach is required that allows an increasing understanding of the problem through successive refinements, and to incrementally grow an effective solution over multiple iterations.

Each iteration ends with an executable release.

Page 14: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Manage RequirementsThe Rational Unified Process describes how to elicit, organize, and document required functionality and constraints; track and document tradeoffs and decisions; and easily capture and communicate business requirements.

Page 15: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Use Component-based Architectures

The Rational Unified Process provides a systematic approach to defining an architecture using new and existing components.

These are assembled in a well-defined architecture, either ad hoc, or in a component infrastructure such as the Internet, CORBA, and COM, for which an industry of reusable components is emerging.

Page 16: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Visually Model Software

The process shows you how to visually model software to capture the structure and behavior of architectures and components. This allows you to hide the details and write code using “graphical building blocks”.

The industry-standard Unified Modeling Language (UML), created by Rational Software, is the foundation for successful visual modeling.

Page 17: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Verify Software Quality

Quality assessment is built into the process, in all activities, involving all participants, using objective measurements and criteria, and not treated as an afterthought or a separate activity performed by a separate group.

Page 18: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Control Changes to SoftwareThe ability to manage change - making certain that each change is acceptable, and being able to track changes - is essential in an environment in which change is inevitable.

The process describes how to control, track and monitor changes to enable successful iterative development. It also guides you in how to establish secure workspaces for each developer by providing isolation from changes made in other workspaces and by controlling changes of all software artifacts (e.g., models, code, documents, etc.).

Page 19: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Two Dimensions of the Process

Dynamic aspect of the process as it is enacted: it is expressed in terms of cycles, phases, iterations, and milestones.

Static aspect of the process: how it is described in terms of activities, artifacts, workers and workflows.

Page 20: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Cycles and Phases

The development cycle is divided in four consecutive phases Inception: a good idea is developed into a vision of the end

product and the business case for the product is presented. Elaboration: most of the product requirements are specified

and the system architecture is designed. Construction: the product is built – completed software is

added to the skeleton (architecture) Transition: the product is moved to user community (beta

testing, training …)

Each cycle results in a new release of the system, and each is a product ready for delivery. This product has to accommodate the specified needs.

Each cycle results in a new release of the system, and each is a product ready for delivery. This product has to accommodate the specified needs.

Page 21: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

IterationsEach phase can be further broken down into iterations. An iteration is a complete development loop resulting in a release (internal or external) of an executable product, a subset of the final product under development, which grows incrementally from iteration to iteration to become the final system.

Each phase can be further broken down into iterations. An iteration is a complete development loop resulting in a release (internal or external) of an executable product, a subset of the final product under development, which grows incrementally from iteration to iteration to become the final system.

Page 22: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Static Structure of the Process

Workers (Roles) define the behavior and responsibilities of an individual (designer, analyst, programmer ...), or a group of individuals working together as a team.

Artifacts are things that are produced, modified, or used by a process (model, document, source code …).

Activities are performed by workers to create or update some artifacts (review design, compile code, perform test …).

Workflows are sequences of activities that produce results of observable value (business modeling, implementation …).

A process describes who is doing what, how, and when using following modeling elements:

Page 23: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Resources and WorkersAllocating resources (individuals) to workers means matching competencies of individuals with the required competencies of the workers.

DesignerArchitectural

Board Programmer

Richard John Mary Laura

WorkersWorkers

ResourcesResources

Page 24: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Management and Technical Artifacts

Technical artifacts may be divided into: Requirements set: business, domain, use case, and analysis

models Design set: design, and test models Implementation set: implementation model, source code,

configuration, and data files Deployment set: deployment model, information about the

way software is actually packaged

The most important kind of artifact are models.

A model is a simplification of reality, created to better understand the system being created.A model is a simplification of reality, created to better understand the system being created.

Page 25: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

The Unified Modeling Language

The Unified Modeling Language (UML) is a standard language for writing software blueprints.

The UML may be used to visualize, specify, construct and document the artifacts of a software-intensive system. Visualizing means graphical language Specifying means building precise, unambiguous, and

complete models Constructing means that models can be directly connected

to a variety of programming languages

Page 26: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Building Blocks of the UML

UML

Things Relationships Diagrams Grouping

Use caseObjectClassInterfaceComponentNode

DependencyAssociationGeneralizationRealization

Use caseClassSequenceCollaborationStatechartActivityComponentDeployment

PackageSubsystemModel

http://www.uml.org

Page 27: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Core Engineering Workflows

Business modeling describes the structure and dynamics of the organization

Requirement describe the use case-based method for eliciting requirements

Analysis and design describe the multiple architectural views

Implementation takes into account sw development, unit test, and integration

Test describes test cases and procedures Deployment covers the deliverable system configuration

Page 28: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Workflows and Models

Business Process Model Domain Model

Use Case Model

Analysis Model

Desing Model Deployment Model

Implementation Model

Test Model

Business ModelingBusiness Modeling

RequirementsRequirements

AnalysisAnalysis

DesignDesign

ImplementationImplementation

TestTest

UML diagrams provide views into

each model

Each workflow is associated with one or more models

Page 29: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Core Supporting Workflows

Configuration Management describes how to control the numerous artifacts produced by the many people who work on a common project (simultaneous update, multiple versions …).

Project Management is the art of balancing competing objectives, managing risk, and overcoming constraints to deliver, successfully, a product which meets the needs of both customers (the payers of bills) and the users.

Environment Workflow provides the software development organization with the software development environment—both processes and tools—that are needed to support the development team.

Page 30: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Exercises

What is the software engineering about? What is the definition of the software negineering?

What is the difference between software process and project? What is the relationship between these both?

Draw the layout of Rational Unified Process and define what the cycles, phases and iterations mean!

Page 31: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Business Modeling

Business Process Modeling (How & When). Business process is a set of one or more linked procedures or activities which collectively realize a business objective or policy goal.

Domain Modeling (Who & What) captures the most important objects in the context of the system. The domain objects represent the entities that exist in environment in which the system works.

The main goal of the business process modeling is to provide common language for communities of software and business engineers.

The main goal of the business process modeling is to provide common language for communities of software and business engineers.

Page 32: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Motivating ExampleDevelop an information system for a car dealer. The application should collect and provide information about customers, their orders, cars, payments etc. The possibility to communicate with the car manufacturer to obtain updated offer of available cars or to order a car required by a customer should be the part of the system. The goal is to make the customer happy!

Page 33: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

UML Diagrams for Business Modeling

Activity Diagram is a variation of a state machine in which the states represent the performance of activities and the transitions are triggered by their completion. The purpose of this diagram is to focus on flows driven by

internal processing. Class Diagram is a graph of elements (in the scope of

business modeling represented by workers and entities) connected by their various static relationships. The purpose of this diagram is to capture static aspect of the

business domain.

Page 34: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Activity Diagram: Car Sale Process

Car Selection

Financing Car Ordering

Car Hand Over

[success]

[not found]

Ref.: Activity diagramfor Financing

InitialState

InitialState

FinalState

FinalState

Action State(Activity)

Action State(Activity)

DecisionDecision

ControlFlow

ControlFlow

NoteNote

Join TransitionJoin Transition

Fork TransitionFork Transition

Page 35: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Swimlanes: Packages of Responsibilities

AccountantSalesmanCustomer

Car Selection

Financing Car Ordering

Car Hand Over

[success]

[not found]

Checking Payment

[Failed][Paid]

Actions may be organized into swimlanes. Swimlanes are a kind of package for organizing responsibility for activities provided by workers.

Actions may be organized into swimlanes. Swimlanes are a kind of package for organizing responsibility for activities provided by workers.

Page 36: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Activities and EntitiesCustomer Salesman Accountant

Car Selection

Financing

[success]

Car Ordering

Car Hand Over

[not found]

Checking Payment

Order

Payment [realized]

Payment [checked]

Object (Entity)Flow

Object (Entity)Flow

EntityEntity

Page 37: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Class Diagram: Car Sale Elements

«worker»Customer

«worker»Salesman

*

communicates

«entity»Order

0..1

defines

*

defines

«entity»Car

specifies

*

orders

«entity»Payment

realizes

takes over

«worker»Accountant

*

checks

* uses

*

hands over

Worker defines the behavior and responsibilities of an individual

Worker defines the behavior and responsibilities of an individual

AssociationAssociation

MultiplicityMultiplicity Entity is the process artifactEntity is the process artifact

Page 38: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Exercises

Install the Poseidon CASE from the web site www.gentleware.com.

Specify activity diagrams for the business processes typical for video lending library.

Page 39: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Alternative Approaches

Integrated Definition – IDEF (U.S. Air Force) http://www.idef.com

Architecture of Integrated Information Systems – ARIS (prof. Scheer) http://www.ids-scheer.com

Business Process Modeling – BPM (prof. Vondrak) http://www.bpr.cz

Page 40: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Requirements

Use Case Model examines the system functionality from the perspective of actors and use cases. Actors: an actor is someone (user) or some thing (other

system) that must interact with the system being developed Use Cases: an use case is a pattern of behavior the system

exhibits. Each use case is a sequence of related transactions performed by an actor and the system in a dialog.

The goal of the requirements workflow is to describe what the system should do by specifying its functionality. Requirements modeling allows the developers and the customer to agree on that description.

The goal of the requirements workflow is to describe what the system should do by specifying its functionality. Requirements modeling allows the developers and the customer to agree on that description.

Page 41: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

UML Diagrams for Requirements Modeling

Use Case Diagram shows the relationships among actors and use cases within a system. The purpose of this diagram is to define what exists outside

the system (actors) and what should be performed by the system (use cases).

Activity Diagram displays transactions being executed by actor and system in their mutual interaction. The purpose of this diagram is to elaborate functionality of the

system specified in a use case diagram.

Page 42: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Use Case Diagram: Car Sale

ActorActor

Use CaseUse CaseSalesman

Car Ordering

Business Monitor

Manager

Car Hand Over

AccountantPayment Checking System

Boundary

System Boundary

Page 43: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Salesman

Production

Car Ordering

«extends» Car is not available.It must be produced.

Car Ordering Payment Checking

Logon Validation

«uses» «uses» Password

IS of Car Producer

Structuring Use Cases

A uses relationship shows behavior that is common to one or more use cases

A uses relationship shows behavior that is common to one or more use cases

An extends relationship shows optional behavior

An extends relationship shows optional behavior

A generalization is the relationship between a more general use case (the parent) and a more specific use case (the child) that is fully consistent with first use case.

A generalization is the relationship between a more general use case (the parent) and a more specific use case (the child) that is fully consistent with first use case.

Page 44: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Structuring Actors

Salesman Accountant

User

Logon Validation

Car Ordering Payment Checking

A generalization is the relationship between a more general actor (theparent) and a more specific actor (the child) that is fully consistent with first actor.

A generalization is the relationship between a more general actor (theparent) and a more specific actor (the child) that is fully consistent with first actor.

Page 45: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Elaborate Functionality of Car Ordering IS of Car ProducerSystemSalesman

Car Specification

Searching for Car

Requirement for Production

Sending Order to Producer

Order Processing

Confirmation of Acceptance

Customer is Informed

[Car Not Found]

[Car Available]

Actor’s responsibility

Actor’s responsibility

Actor’s responsibility

Actor’s responsibility

System transactions

System transactions

Page 46: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Exercises

For the business processes specified during business modeling workflow identify actors and their use cases.

Specify activity diagram for the lending process.

Page 47: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Analysis & Design

Analysis Model examines requirements from the perspective of objects found in the vocabulary of the problem domain.

Design Model will further refine the analysis model in light of the actual implementation environment. The design model serves as an abstraction of the source code; that is, the design model acts as a 'blueprint' of how the source code is structured and written.

Deployment Model establishes the hardware topology on which the system is executed.

The goal of the analysis & design workflow is to show how the system will be realized in the implementation phase.

Page 48: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

UML Diagrams for Analysis & Design

Class Diagram shows set of classes, interfaces and their relationships Class diagrams address the static design view of the system.

Sequence Diagram is an interaction diagram that emphasizes the time ordering of messages.

Collaboration Diagram displays object interactions organized around objects and their links to one another An interaction diagram that emphasizes the structural

organization of objects that send and receive messages. Statechart Diagram shows the life history of a given class and

the events that cause a transition from one state to another Deployment Diagram shows the configuration of run-time

processing elements The purpose of this diagram is to model the topology of

hardware which the system executes.

Page 49: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Use Cases and ObjectsObjects are enablers of the sequence of transactionsrequired by the use case. Use cases and objects are different views of the same system. An object can therefore typically participate in several use cases.

Objects are enablers of the sequence of transactionsrequired by the use case. Use cases and objects are different views of the same system. An object can therefore typically participate in several use cases.

AccountantSalesman

Objects

Use Cases

Order

WarehouseManager

Page 50: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

What is an Object?

An Object is an identifiable individual entity with: Identity: a uniqueness which distinguishes it from all other

objects Behavior: services it provides in interactions with other

objects Secondary properties:

Attributes: some of which may change with time Lifetime: from creation of the object to its destruction States: reflecting different phases in the object’s lifecycle

Page 51: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Views of Object

External responsibilities of that object services provided visible properties and associations externally visible protocols and interactions

Internal data representations implementations of behaviors

Page 52: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Relationships Among Objects

LinksA link is a physical or conceptual connection between objects (John Smith works-for Simplex company). Mathematically, a link is defined as a tuple, that is, an ordered list of objects.

Page 53: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Objects and Their Interactions

A set of interconnected objects constitutes the system Interactions between objects result in:

Collective behaviors being exercised Changes in the logical configurations and states of the

objects and system

Page 54: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

TimeTime

Sequence Diagram: Car Ordering

order:Salesman warehouse car database selected car

fill in info

submit

search for (car)

select (car)

* [not found] iterate

car found (selected)

car found (selected)

is reserved?

not reserved

reserve

car reserved

Activation (focus of control) shows the period during which an activity is performed

Activation (focus of control) shows the period during which an activity is performed

Asynchronous message; the sender dispatches the Stimulus and immediately continues with the next step in the execution.

Asynchronous message; the sender dispatches the Stimulus and immediately continues with the next step in the execution.

Synchronous message (procedure call); the sender waits for the response (return message).

Synchronous message (procedure call); the sender waits for the response (return message).

While loop; the message is repeated until the condition is fulfilled

While loop; the message is repeated until the condition is fulfilled

Return message; response to the sender

Return message; response to the sender

ObjectObject

Page 55: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

order:Salesman warehouse car database

fill in info

submit

search for (car)

select (car)

* [not found] iterate

car not found

car not found

order (car)

accepted

car reserved

:IS of CarProducer

Alternative ScenarioExternal Information

System

External Information System

Object LifelineObject Lifeline

Page 56: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

order:Salesman warehouse car database selected car

fill in info

submit

search for (car)

select (car)

* [not found] iterate

not reserved

reserve

car reserved

:IS of CarProducer

[car found] is reserved?

[car not found] order(car)

accepted

Merging Scenarios

BranchingBranching

Joining scenarios

Joining scenarios

Page 57: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

What is a Class?

Classes are found by examining the objects in sequence diagrams. Every object is an instance of one class. Classes should be named using the vocabulary of the domain.

A class is the descriptor for a set of objects with common structure, behavior, relationships and semantics.A class is the descriptor for a set of objects with common structure, behavior, relationships and semantics.

Page 58: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

CarOrder Warehouse

CarDatabase

selected : Car : Car

myCar : Car

anOrder : Order

Objects and ClassesClasses identified in the domain. All classes are singular nouns starting with uppercase letter.

Classes identified in the domain. All classes are singular nouns starting with uppercase letter.

Objects (instances) instantiated from classes. A name of object is underlined. Colon separates the name and the class of the object. Names usually start with lowercase letter.

Objects (instances) instantiated from classes. A name of object is underlined. Colon separates the name and the class of the object. Names usually start with lowercase letter.

Page 59: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Operations

The behavior of a class is represented by its operations. Operation may be found by examining interaction

diagrams

: Order : Warehouse

search for (car)

searchFor(in c : Car)

Warehouse

Page 60: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Attributes

The structure of a class is represented by its attributes. Attributes may be found by examining class definitions, the

problem requirements, and applying domain knowledge.

A customer has chosen a model of the car and has to pay for it some price.

customer : Stringmodel : Stringprice : float

Order

Page 61: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

isReserved() : booleanreserve()assign(in num : Long)

model : Stringvin : longreserved : boolean

Car

submit()filIIn(in model : String, in extras : String)

customer : Stringmodel : Stringprice : float

Order

model : String = Ferrari Modenavin : long = 987654321reserved : boolean = true

selected : Car

model : Stringvin : longreserved : boolean

: Car

model : String = Honda Accord 2.0i ESvin : long = 123456789reserved : boolean = true

myCar : Car

customer : String = Richard Geremodel : String = Ferrari Modenaprice : float = 150000

anOrder : Order

Operations and AttributesAttributes and their types

Attributes and their types

Operations, their parameters and return values

Operations, their parameters and return values

Values held by the object

Values held by the object

Page 62: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Relationships

Relationships between classes specify a way for communication between objects.

Sequence and/or collaboration diagrams are examined to determine what links between objects need to exist to accomplish required behavior. Objects can send messages to each other only if the link between them is established. An sequence diagram emphasizes the time ordering of

messages. An collaboration diagram emphasizes the structural

organization of objects that send and receive messages.

Page 63: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

: Order:Salesman : Warehouse : CarDatabase

searchFor(c:Car)

select(c:Car)

*[not found]: iterate()

submit()

selected : Car

filIIn(model:String, extras:String)

selected:Car

selected:Car

getSpec()

c : Car

<<destroy>>

isReserved()

false

reserve()

reserved

<<create>>

Refined Sequence Diagram

Synchronous message with arguments

Synchronous message with arguments

Object creation (stereotype create)Object creation (stereotype create)

Object destruction(asynchronous message)

Object destruction(asynchronous message)

RecursionRecursion

Page 64: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

:Salesman

: Order

1: filIIn(model:String, extras:String)2: reserved:=submit()

c : Car

: Warehouse

: CarDatabase

selected : Car

2.1: selected:=searchFor(c:Car)

«global »

«lo

ca

l »

2.2

: s

ele

cte

d:=

se

lec

t(c

:Ca

r)

«a

ss

oc

iati

on

»

2.2

.1 *

[n

ot

fou

nd

] i:

ite

rate

()

1.1

: <

<c

rea

te>

>

2.3

: <

<d

es

tro

y>

>

2.2.1.1: getSpec()

«parameter »

<<self>>

Collaboration Diagram

Link between objectsLink between objects

Synchronous message with arguments

Synchronous message with arguments

Asynchronous messageAsynchronous message

Return valueReturn value

Message orderMessage order

Visibility (local stereotype)

Visibility (local stereotype)

Page 65: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Types of Relationships Association describes a group of links with common

structure and common semantics (a Person works-forworks-for aCompany). An association a bi-directionalbi-directional connection between classes that describes a set of potential links in the same way that a class describes a set of potential objects.

Aggregation is the “part-whole” or “a-part-of” relationshipin which objects representing the componentscomponents of somethingare associated with an object representing the entire assemblyassembly.

Dependency is a weaker form of relationship showing a relationship between a clientclient and suppliersupplier.

Generalization is the taxonomic relationship between a more generalgeneral element (the parent) and a more specificspecific element (the child) that is fully fully consistentconsistent with the first element and that adds additional information.

Page 66: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Links and Associations

L1L2

L3

L5

L4

P1

P2

L1 : Line

Line Point

L2 : Line

L3 : Line

L4 : Line

L5 : Line

P1 : Point

P2 : Point

2..* 0..*

RealityReality

Links among objects

Links among objects

AssociationAssociation

MultiplicityMultiplicity

Page 67: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Association Classes

name : Stringssn : String

Salesman

order(in c : Car)

ProductionOrder

startSession()

login : Stringpassword : Stringsession : int

Authorization

1 0..*

verify(in login, in passwd) : boolean

Users

0..* 1

Modeling anassociationas a class

Modeling anassociationas a class

Association Class is an association that also has class properties (or a class that has association properties).

Association Class is an association that also has class properties (or a class that has association properties).

Association between classes

Association between classes

Page 68: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

select(in c : Car)iterate()

CarDatabase

isReserved()reserve()assign(in num : Long)getSpec()

model : Stringvin : longreserved : boolean

Car

0..*

price : float

LuxuryPackage

automatic : boolean

AirCondition

color : int

LeatherSeats

numOfSpeakers : int

Audio

Aggregations

Shared aggregation; the part may be contained in other aggregates.

Shared aggregation; the part may be contained in other aggregates.

Composition; the part is strongly owned by the composite and may not be part of any othercomposite.

Composition; the part is strongly owned by the composite and may not be part of any othercomposite.

PartPart

AggregateAggregate CompositeComposite

Page 69: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

isReserved()reserve()assign(in num : Long)getSpec()

model : Stringvin : longreserved : boolean

Car

submit()filIIn(in model : String, in extras : String)

customer : Stringmodel : Stringprice : float

Order

searchFor(in c : Car)

Warehouse«uses»

*

1

<<instantiate>>

Dependency

The most common kind of dependency relationship is the connection between a class that only uses another class as a parameter to an operation.

The most common kind of dependency relationship is the connection between a class that only uses another class as a parameter to an operation.

The client class uses the supplier to create its instance.

The client class uses the supplier to create its instance.

Association with navigationAssociation with navigation

Page 70: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Roles, Types and Interfaces

RoleRole is the named specific behavior of an object participating in a particular context (the face it presents to the world at a given moment).

TypeType specifies a domain of objects together with the operations applicable to the objects (without defining the physical implementation of those objects).

InterfaceInterface is the named set of externally-visible operations. Notions of rolerole, typetype and interfaceinterface are interchangeable.

Page 71: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Type and Implementation Class

submit()filIIn(in model : String, in extras : String)

customer : Stringmodel : Stringprice : float

Order

isReserved()reserve()assign(in num : Long)getSpec()

model : Stringvin : longreserved : boolean

Carspecified

selected

getSpec()

«interface»Specified isReserved()

reserve()

«interface»Selected

isReserved()reserve()assign(in num : Long)getSpec()

model : Stringvin : longreserved : boolean

Car

isReserved()reserve()assign(in num : Long)getSpec()

model : Stringvin : longreserved : boolean

Car

Specified

Selectedsubmit()filIIn(in model : String, in extras : String)

customer : Stringmodel : Stringprice : float

Order

«uses»

«uses»

RoleRoleType specified by the interface

Type specified by the interface

Implementation class defines the physical data structure (for attributes and associations) and methods of an object.

Implementation class defines the physical data structure (for attributes and associations) and methods of an object. InterfaceInterface

RealizationRealization

Page 72: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Implementation Independence

getSpec()

«interface»Specified isReserved()

reserve()

«interface»Selected

isReserved()reserve()assign(in num : Long)getSpec()

model : Stringvin : longreserved : boolean

Car

getSpec()

«interface»Specified isReserved()

reserve()

«interface»Selected

isReserved()reserve()assign(in num : Long)getSpec()

num : longreserved : boolean

Motorcycle

+submit()+filIIn(in model : String, in extras : String)

-customer : String-model : String-price : float

Order

+isReserved()+reserve()+assign(in num : Long)+getSpec()

-num : long-reserved : boolean

Motorcycle

Selected

Specified

«uses»

«uses»

Interface for Order remains the

same!

Interface for Order remains the

same!

Page 73: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

automatic : boolean

AirCondition

color : int

LeatherSeats

numOfSpeakers : int

Audio

size : Stringtype : String

AluWheels

numOfCDs : int

CDPlayer MCPlayer

setDiscount(in d : float)

price : int

Accessory

Generalization/Specialization

Inheritance: re-use of implementation

Inheritance: re-use of implementation

SuperclassSuperclass

Subclass. Each subclass can define its own implementation of attributes and services.

Subclass. Each subclass can define its own implementation of attributes and services.

GeneralizationGeneralization

Page 74: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Visibility

Public declaration is accessible to all clients. Protected declaration is accessible only to the class itself and

its subclasses. Private declaration is accessible only to the class itself.

-privateOper()#protectedOper()+publicOper()

-privateAttr#protectedAttr+publicAttr

Visibility

Another#protectedRole

*

+publicRole

*

Page 75: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Class Diagram

submit()filIIn()

customermodelprice

Order

isReserved()reserve()assign()getSpec()

modelvinreserved

Car#specified

select()iterate()

CarDatabase

0..*

#selected

price

Package

setDiscount()

price

Accessory

LuxuryPackage

1

#package

0..2

SportPackage

#extras0..*automatic

AirCondition

color

LeatherSeats

numOfSpeakers

Audio

sizetype

AluWheel

1

5

A class diagram is a graphic view of the static structural model.

A class diagram is a graphic view of the static structural model.

Abstract Class: class that cannot be directly instantiated.

Abstract Class: class that cannot be directly instantiated.

Page 76: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Exercises

Identify the objects and their classes based on sequence diagram of lending process. Specify what operations and attributes these classes should implement.

Apply generalization/specialization relationship to classes Videotape and DVD.

Construct class diagram for video lending library.

Page 77: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

The Dynamic Behavior of an Object

A state transition (statechart) diagram shows The life cycle of a given object The events causing a transition from one state to another The actions that result from a state change

State transition diagrams are created for objects with significant dynamic behavior

Sequence and/or collaboration diagrams are examined to define statechart diagram of a class

Page 78: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Initializing

filIIn(model,extras)

Car Ordering

submit()

Initializing

filIIn(model,extras)

searchFor(c)

Searching

submit()

isReserved()

Checking Reservation

[selectedCar] / destroy

reserve()

Reservation

[false]

Statechart Diagram

: Order

«create »

searchFor(c: Car)

submit()

filIIn(model:String, extras:String)

selected:Car

<<destroy>>

isReserved()

reserve()

false

reserved

A statechart diagram for a class Order

A statechart diagram for a class Order

StateState

External event

External event

CompositeState

CompositeState

GuardGuard

ActionAction

Page 79: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Merging ScenariosInitializing

filIIn(model,extras)

searchFor(c)

Searching

submit()

isReserved()

Checking Reservation

[selectedCar] / destroy

reserve()

Reservation

[false]

order(c:Car)

Production Request[car not found]

[accepted]

: Order

«create » create

searchFor(c: Car)

submit

filIIn

car not found

order(c:Car)

accepted

reserved

Page 80: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Exercises

Select two classes from video lending library class diagram and construct the state diagram for both of them.

Page 81: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Model Management Overview A package is a general-purpose mechanism for organizing

elements into groups to manage complexity of modeling structures

A subsystem is a grouping of model elements that represents a behavioral unit in a physical (real) system. to describe the services offered by the subsystem to describe the interface of the subsystem

A model is a simplification of reality, an abstraction of a system, created in order to better understand the system A partitioning of the abstraction that visualize, specify,

construct and document that system Subsystems and Models are special cases of package

Page 82: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Packages

GUI

Windows

Sales

Warehouse

<<import>>

<<import>> <<import>>

+Warehouse+Car#CarDatabase

+Order

+Window+TextArea+Button

Motif

PackagePackage

Import relationship adds the contents of the target to the source namespace.

Import relationship adds the contents of the target to the source namespace.

ExportExport

Structuring of Car Ordering subsystem.

Structuring of Car Ordering subsystem.

Page 83: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Design

In analysis domain objects are the primary focus. In design the other layers are added and refined

User Interface Distribution Persistence Mechanism

The design model will further refine the analysis model in light of the actual implementation environment.The design model will further refine the analysis model in light of the actual implementation environment.

Page 84: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Goal of Design

Definition of the system architecture Identifying design patterns and frameworks Software components definition and re-use

Mapping of analysis models into a set of software components with precisely defined interactions based on system architecture and already existing components

Mapping of analysis models into a set of software components with precisely defined interactions based on system architecture and already existing components

Page 85: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

+addElement(in o : java.lang.Object)+removeElement(in removeElement : java.lang.Object) : boolean+elements() : java.lang.Object[]+elementAt(in elementAt : int) : Object

-elementCount : int = 0

java.util.Vector

+select(in c : Car)+iterate()

CarDatabase

1

-container

1

+isReserved()+reserve()+assign(in num : Long)+getSpec()

-model : String-vin : long-reserved : boolean

Car

#elementData0..*

1

-actual

1

+hashCode() : int#clone() : Object

java.lang.Object

Mapping into Software Components

+select(in c : Car)+iterate()

CarDatabase

+isReserved()+reserve()+assign(in num : Long)+getSpec()

-model : String-vin : long-reserved : boolean

Car

0..*

Analysis ModelAnalysis Model

Design ModelDesign Model

Implementation Environment

Implementation Environment

Page 86: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

System ArchitectureThe organizational structure and associated behavior of a system.The organizational structure and associated behavior of a system.

User InterfaceCore = ModelDB - Persistence

Distribution

Adapter object

Adapter object

Page 87: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

: CarDatabase

con : java.sql.Connection

sql : java.sql.Statement

rs : java.sql.ResultSet

1: s

ql:=

crea

teS

tate

men

t()

2: rs:=executeQuery("SELECT * FROM Cars")

3.i.1: model:=getString("m

odel")

3.i.2: vin:=getLong("vin")

3.i.3: reserved:=getBoolean("reserved")

car : Car

«cre ate » 3

. i.4:3. i.5

: assign(m

ode l,vin, res erve d)

: java.util.Vector

3.i.6: a

ddElement(car)

For all elements from result set

3.i *

[i=1

..n]:

pop

ula

te()

Interface to DatabasePopulating CarDatabase object from relational database

Populating CarDatabase object from relational database

Adapter to relational database

Adapter to relational database

Page 88: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Design Patterns

The design pattern concept can be viewed as an abstraction of imitating useful parts of other software products.

The design pattern is description of communicating objects and classes that are customized to solve a general design problem in a particular context.

Page 89: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Classification of Design Patterns

Creational patterns defer some part of object creation to a subclass or another object.

Structural patterns composes classes or objects. Behavioral patterns describe algorithms or cooperation of

objects.

Page 90: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Factory – Creational PatternIntent - provide an interface for creating families of related objects without specifying their concrete classes.

Motivation +open()+close()

-x : int-y : int-width : int-height : int-backgound : int

Window

Order

WinLookWindow

MotifLookWindow

+align(in type : int)

-font

TextArea

WinLookTextArea

MotifLookTextArea

-window

-area

«instantiate»

«instantiate»{OR}

«instantiate»

«instantiate»{OR}

ConstraintConstraint

Page 91: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Factory - Solution

Order

Window

-window

WinLookWindow MotifLookWindow

TextArea

-area

MotifLookTextAreaWinLookTextArea

+createWindow() : Window+createTextArea() : TextArea

Factory

-factory

+createWindow() : Window+createTextArea() : TextArea

WinLookFactory

+createWindow() : Window+createTextArea() : TextArea

MotifLookFactory

«instantiate»

«instantiate»

«instantiate»

«instantiate»

return new MotifLookWindow();return new MotifLookWindow();

return new MotifLookTextArea();return new MotifLookTextArea();

Page 92: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Factory - AbstractionClient

AbstractProductA

-productA

ProductA2 ProductA1

AbstractProductB

-productB

ProductB1ProductB2

+createProductA() : AbstractProductA+createProductB() : AbstractProductB

AbstractFactory

-factory

+createProductA()+createProductB()

ConcreteFactory2

+createProductA()+createProductB()

ConcreteFactory1

«instantiate»

«instantiate»

«instantiate»

«instantiate»

Abstract Class: class without instances

Abstract Class: class without instances

Page 93: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Composite – Structural PatternIntent - compose objects into tree structures to represent part-whole hierarchies. Composite lets client treat individual objects and compositions of objects uniformly.

Motivation

Car

getPrice()

Accessory add(in a : Accessory)remove(in a : Accessory)getChild(in index : int)

Package

getPrice()

AirCondition

getPrice()

Audio

getPrice()

LeatherSeats

-package*

-accessory*

1..*

Page 94: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Composite - Solution

Caradd(in a : Accessory)remove(in a : Accessory)getChild(in index : int)getPrice()

Accessory-accessory

getPrice()

AirCondition

getPrice()

Audio

getPrice()

LeatherSeats

add(in a : Accessory)remove(in a : Accessory)getChild(in index : int)getPrice()

Package

-accessory

1..*

Page 95: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Composite - Abstraction

add(in a : Component)remove(in a : Component)getChild(in index : int)operation()

Component

operation()

Leaf

add(in a : Component)remove(in a : Component)getChild(in index : int)operation()

Composite

-component

1..*

for all componentsoperation()

empty body

Client

Page 96: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Observer – Behavioral PatternIntent - define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.

Motivation

paid()toString() : String

amount : floatdueDate : Datedate : Date

Invoice

send(in invoice : String)

phone : String

SMSGate

-manager

-salesman

display(in inv : Invoice)

PaymentMonitor-accountant

manager.send(toString());salesman.send(toString());accountant.display(this);

Page 97: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

attach(in o : Observer)detach(in o : Observer)notify()

Subject

update()

Observer-observer

*

-subject

paid()toString() : String

amount : floatdueDate : Datedate : Date

Invoice

send(in invoice : String)update()

phone : String

SMSGate

display(in inv : Invoice)update()

PaymentMonitor

for all observerobserver.update()

send(subject.toString()) display(subject)notify()

Observer - Solution

Page 98: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Observer – Solution (Collaboration)

Multi-Object: a set of objects of the same class

Multi-Object: a set of objects of the same class

IterationIteration

banking

: Invoice : SMSGate

: PaymentMonitor

1.1.i * [i=1..2]: update()1.1.i.1: text:=toString()

subjectobserver

1.1: notify()

«se

lf »

1: p

aid

()

1.1.i.2: send(text)

«se

lf »

1.1.3.1: display(subject)

«se

lf »

Page 99: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Observer - Abstraction

attach(in o : Observer)detach(in o : Observer)notify()

Subject

update()

Observer-observer

*

-subject

getState()stateChanged()

ConcreteSubject

update()

ConcreteObserver

for all observerobserver.update()

subject.getState()notify()

Page 100: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Exercises

Describe the design pattern Observer. Try to integrate desing pattern Observer into the design of

video lending library.

Page 101: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Frameworks A set of abstract and concrete classes that comprise a

generic software subsystem. Framework is calling our classes => full control of flow

Class1

+isReserved()+reserve()+assign(in num : Long)+getSpec()

-model : String-vin : long-reserved : boolean

Car

Class_nClass_i

1..* 1 0..*

Honda

+add(in a : Accessory)+remove(in a : Accessory)+getChild(in index : int)+getPrice()

Package

ES LS

User Level

Page 102: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

MVC – Application Framework

Any application can be divided into two parts: The domain model, which handles data storage and

processing. The user interface, which handles input and output.

Model-View-Controller Architecture Model: domain state and behavior (dynamic object). View: display current state of dynamic object. Controller: effect user-evoked behavior from the dynamic

object.

Page 103: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

MVC Classes

ModeladdDependent(View v)removeDependent(View v)notify()

Controllermenu()mouseClicked()keyPressed()...

Viewupdate()display()

dependent

Input from user Output

*

Page 104: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

MVC ExampleModeladdDependent(View v)removeDependent(View v)notify()

Controllermenu()mouseClicked()keyPressed()

Viewupdate()display()

dependent

CounterControllerincrement()decrement()

Counterint statesetState(int value)getState()increment()decrement()

CounterViewTextField fieldupdate()

model.increment()

state = value;this.notify(); value = getState()+1;

setState(value);

value = model.getState();field.setText(value);display();

model

model

Page 105: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Deployment Model

Deployment diagram shows the configuration of run-time processing elements

The purpose of this diagram is to model the topology of hardware which the system executes.

Page 106: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Deployment Diagram

<<workstation>>Salesman 1

<<workstation>>Salesman 2

<<workstation>>Accountant

<<workstation>>Manager

<<network>>LAN

<<server>>Showroom

<<network>> Internet

<<SQL server>>Warehouse

<<ERP>>Production

WorkstationWorkstation

NetworkNetwork

ServerServer

Server running SQL database

Server running SQL database

Page 107: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Implementation

Implementation Model describes how elements in the design model, such as design classes, are implemented in terms of components such as a source code files, executables, and so on. The implementation model also describes how the components are organized according to the structuring and modularization mechanism available in the implementation environment and the programming language (e.g. package in Java).

The goal of the implementation workflow is to flesh out the designed architecture and the system as a whole.

Page 108: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

UML Diagrams for Implementation

Component Diagram illustrates the organization and dependencies among software components – physical and replaceable part of a system that conforms to and provides the realization of a set of interfaces. A component may be A source code component A binary or executable component Others (database tables, documents) …

Deployment Diagram is refined to show the configuration of run-time processing elements and the software components, processes, and objects that execute on them.

Page 109: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Mapping

Analysis & Design

ClassRole, Type, InterfaceOperationAttribute (Class)Attribute (instance)AssociationDependency

Interaction betweenobjectsUse CasePackage/Subsystem

Source code (Java)

ClassInterfaceMethodStatic variableInstance variableInstance variablesLocal variable or argument in method or return valueCall to a method

Sequence of callsPackage

Page 110: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Design Results

+isReserved() : boolean+reserve()+assign(in num : Long)+getSpec() : String

#model : String#vin : long#reserved : boolean

Car

+add(in a : Accessory)+remove(in a : Accessory)+getChild(in index : int) : Accessory+getPrice() : float

Accessory

+accessory

+getPrice() : float

AirCondition

+getPrice() : float

Audio

+getPrice() : float

LeatherSeats

+add(in a : Accessory)+remove(in a : Accessory)+getChild(in index : int) : Accessory+getPrice() : float

Package

-accessory

1..*

+submit() : boolean+filIIn(in model : String, in extras : String)

#customer : String#price : float

OrderSpecified

Selected

+searchFor(in s : Specified) : Selected

Warehouse

#warehouse

Page 111: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Component Diagram: Source Code

File ComponentFile Component

Dependency Relationship

Dependency Relationship

Contained classes:AccessoryPackageAirConditionAudioLeatherSeats

Contained classes:AccessoryPackageAirConditionAudioLeatherSeats

«file»Order.java

«file»Car.java

«import»

«file»Selected.java

«file»Specified.java

«friend»

«friend»

«file»Accessory.java

«friend»

«file»Warehouse

«import»

«import»

Page 112: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Source Code: Order.java

import cars.Car;import warehouse.Warehouse;public class Order {

protected String customer;protected float price;protected Specified specified;protected Selected selected;protected Warehouse warehouse;

public void fillIn(String model, String extras) { Specified specified = new Car(model, extras);

}public boolean submit() {

// warehouse is assigned through networkselected = warehouse.searchFor(specified);if (selected.isReserved())

return false;selected.reserve();return true;

}}

import cars.Car;import warehouse.Warehouse;public class Order {

protected String customer;protected float price;protected Specified specified;protected Selected selected;protected Warehouse warehouse;

public void fillIn(String model, String extras) { Specified specified = new Car(model, extras);

}public boolean submit() {

// warehouse is assigned through networkselected = warehouse.searchFor(specified);if (selected.isReserved())

return false;selected.reserve();return true;

}}

+isReserved()+reserve()+assign(in num : Long)+getSpec()

#model : String#vin : long#reserved : boolean

Car

+submit() : boolean+filIIn(in model : String, in extras : String)

#customer : String#price : float

OrderSpecified

Selected

+searchFor(in s : Specified) : Selected

Warehouse

#warehouse

Page 113: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Specified.java, Selected.java, Car.java

package cars;public interface Selected {

boolean isReserved();void reserve();

}

package cars;public interface Selected {

boolean isReserved();void reserve();

}

package cars;public interface Specified {

String getSpec();}

package cars;public interface Specified {

String getSpec();}

package cars;public class Car implements Specified, Selected {

protected String model;protected long vin;protected boolean reserved;public Accessory accessory;

public boolean isReserved() {return reserved;

}public void reserve() {

reserved = true;}public void assign(long num) {

vin = num;}public String getSpec() {

return model;}

}

package cars;public class Car implements Specified, Selected {

protected String model;protected long vin;protected boolean reserved;public Accessory accessory;

public boolean isReserved() {return reserved;

}public void reserve() {

reserved = true;}public void assign(long num) {

vin = num;}public String getSpec() {

return model;}

}

+isReserved() : boolean+reserve()+assign(in num : Long)+getSpec() : String

#model : String#vin : long#reserved : boolean

Car

+add(in a : Accessory)+remove(in a : Accessory)+getChild(in index : int) : Accessory+getPrice() : float

Accessory

+accessory

Specified

Selected

Page 114: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Accessory.javapackage cars;public abstract class Accessory {

public void add(Accessory a) {}public void remove(Accessory a) {}public Accessory getChild(int index) {

return null;}public abstract float getPrice();

}

class AirCondition extends Accessory {public float getPrice() {

return 2000.0f;}

} // other “friend” classesclass Package extends Accessory {

private Accessory[] accessory;

public void add(Accessory a) {/*code*/}public void remove(Accessory a) {/*code*/}public Accessory getChild(int index) {

return accessory[index];}public float getPrice() {

float sum=0;for (int i=0; i < accessory.length; i++) {

sum = sum + accessory[i].getPrice();}return sum;

}}

package cars;public abstract class Accessory {

public void add(Accessory a) {}public void remove(Accessory a) {}public Accessory getChild(int index) {

return null;}public abstract float getPrice();

}

class AirCondition extends Accessory {public float getPrice() {

return 2000.0f;}

} // other “friend” classesclass Package extends Accessory {

private Accessory[] accessory;

public void add(Accessory a) {/*code*/}public void remove(Accessory a) {/*code*/}public Accessory getChild(int index) {

return accessory[index];}public float getPrice() {

float sum=0;for (int i=0; i < accessory.length; i++) {

sum = sum + accessory[i].getPrice();}return sum;

}}

+add(in a : Accessory)+remove(in a : Accessory)+getChild(in index : int) : Accessory+getPrice() : float

Accessory

+getPrice() : float

AirCondition

+getPrice() : float

Audio

+getPrice() : float

LeatherSeats

+add(in a : Accessory)+remove(in a : Accessory)+getChild(in index : int) : Accessory+getPrice() : float

Package

-accessory

1..*

Page 115: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Component Diagram: Binaries

«file»Accessory.java

«executable»Accessory.class

«executable»Package.class

«executable»AirCondition.class

«executable»Audio.class

«executable»LeatherSeats.class

«compilation» «compilation»

«compilation»

«compilation»

«compilation»

Source Code FileSource Code File

Compiled (Java Bytecode) File

Compiled (Java Bytecode) File

Page 116: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Component Diagram: Run-Time

«executable»CarDatabase.class

«library»rt.jar

«executable»sql.exe

«table»Cars

«executable»java.exe

«document»font.properties

Configuration Document

Configuration Document

SQL ServerSQL Server

Relational TableRelational TableJava Virtual Machine

Java Virtual Machine

Compiled Source File

Compiled Source File

Java Run-Time Library

Java Run-Time Library

Page 117: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Refined Deployment Diagram

<<server>> Showroom

<<server>> Warehouse

«executable»CarDatabase.class

«executable»sql.exe

«executable»java.exe

«table»Cars

«document»font.properties

«library»rt.jar

Showroom Server

Showroom Server

Warehouse Server

Warehouse Server

Page 118: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Unit Tests

Specification testing, or "black-box testing" verifies the unit's externally observable behavior

Structure testing, or "white-box testing", verifies the unit's internal implementation

Integration and system tests must be done to ensure that several components behave correctly when integrated

Other tests of performance, memory usage and load

The purpose of performing a unit test is to test the implemented components as individual units. The following types of unit testing are done:

Page 119: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Exercises

Based on class diagram of video lending library define the source component diagram.

For the two classes with state diagram specified write the source code in Java programming language.

Page 120: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Test

The purposes of testing are: Plan the tests required in each iteration, including integration

tests and system tests. Integration tests are required for every build within the iteration, whereas system tests are required only at the end of the iteration.

Design and implement the tests by creating test cases that specify what to test, creating test procedures that specify how to perform the tests, and creating executable test components to automate the tests if possible

Perform the various tests and systematically handle the results of each test. Builds found to have defects are retested and possibly sent back to other core workflows, such as design and implementation, so that the significant defects can be fixed.

Tests are carried out along three quality dimensions reliability, functionality, and system performance. Testing is related to all models and their diagrams!!!

Tests are carried out along three quality dimensions reliability, functionality, and system performance. Testing is related to all models and their diagrams!!!

Page 121: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Verification and Validation

Verification: Are we building the product right? => The discovery of defects in the system.

Validation: Are we building the right product? => The assessment of whether or not the system is usable in an operational situation.

Verification and validation (V&V) is the term for checking processes which ensure that the software meets its requirements and that the requirements meet the needs of software procurer.

Verification and validation (V&V) is the term for checking processes which ensure that the software meets its requirements and that the requirements meet the needs of software procurer.

Page 122: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Static and Dynamic V&V Static techniques are concerned with the analysis of the

system representation such as the requirements, analysis, design and program listing. ST can only check the correspondence between a program and its specification (verification).

Dynamic techniques involve exercising an implementation. DT can demonstrate that the software operation is useful (validation). Static

verification

Staticverification

RequirementsRequirements AnalysisAnalysis DesignDesign ImplementationImplementation

PrototypePrototype Dynamicvalidation

Dynamicvalidation

Page 123: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Test Model

Test Model is a collection of: Test cases, which specify what to test in the system. Test procedures, which specify how to perform the test

cases. Test components, which automate the test procedures

Page 124: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Test Case

The following are common test cases: A test case that specifies how to test a use case or a specific

scenario of a use case. Such a test case includes verifying the result of the interaction between the actor and the system ("black-box" test). Black-box test is the test of the externally observable behavior of the system

A test case that specifies how to test a use case realization. Such a test case includes verifying the interaction between the components implementing the use case ("white-box" test). White-box test is the test of the internal interaction between components of the system

Test case specifies one way of testing the system, including what to test with which input, and under which condition to test.

Test case specifies one way of testing the system, including what to test with which input, and under which condition to test.

Page 125: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Test Procedure

Test procedures can be based on the following: Instructions for an individual on how to perform a test case

manually Description of how to create executable test components Specifications of how to interact with a test automation tool

Test procedure specifies how to perform one or several test cases or parts of them. Test procedure specifies how to perform one or several test cases or parts of them.

Page 126: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Test Component

Test components can be developed using: Scripting language or a programming language Test automation tool

Test component automates one or several test procedures or parts of them. Test components are used to test the components in the implementation model by providing test inputs, controlling and monitoring the execution of the tested component, and possibly reporting the test results.

Test component automates one or several test procedures or parts of them. Test components are used to test the components in the implementation model by providing test inputs, controlling and monitoring the execution of the tested component, and possibly reporting the test results.

Page 127: Software Engineering Prof. Ing. Ivo Vondrak, CSc. Dept. of Computer Science Technical University of Ostrava ivo.vondrak@vsb.cz .

Deployment

Producing external releases of the software. Packaging the software. Distributing the software. Installing the software. Providing help and assistance to users. Planning and conduct of beta tests. Migration of existing software or data.

The purpose of the deployment workflow is to successfully produce product releases, and deliver the software to its end users. It covers a wide range of activities including: