Software Engineering I (02161) Week 1 Assoc. Prof. Hubert - - PowerPoint PPT Presentation

software engineering i 02161
SMART_READER_LITE
LIVE PREVIEW

Software Engineering I (02161) Week 1 Assoc. Prof. Hubert - - PowerPoint PPT Presentation

Software Engineering I (02161) Week 1 Assoc. Prof. Hubert Baumeister Informatics and Mathematical Modelling Technical University of Denmark Spring 2010 2010 H. Baumeister (IMM) c Software Engineering I (02161) Spring 2010 1 / 94


slide-1
SLIDE 1

Software Engineering I (02161)

Week 1

  • Assoc. Prof. Hubert Baumeister

Informatics and Mathematical Modelling Technical University of Denmark

Spring 2010

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 1 / 94

slide-2
SLIDE 2

Practical Information

Who are we?

110 students with different backgrounds

Bachelor Softwaretek.: 66 Bachelor It og Kom.: 39 Other: 5

Teacher

Hubert Baumeister, Assoc. Prof. at DTU Informatik (hub@imm.dtu.dk; office 322.010) 3 Teachingassistants

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 3 / 94

slide-3
SLIDE 3

Practical Information

Course activities

Lectures every Monday 13:00 — approx 14:45 (Lecture plan is on the course Web page) Exercises in the E-databar (341.003+015)

Teaching assistants will be present : 15:00 — 17:00 Expected work at home: 5 hours (lecture preparation; exercises, . . . ) No hand-in of the solutions, but show the solutions to the TA or me for feedback

Examination

Last 5 weeks: exam project in groups (2—4)

Software + Report

no written examination

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 4 / 94

slide-4
SLIDE 4

Practical Information

Course material

Course Web page: http://www.imm.dtu.dk/courses/02161 contains

practical information: (e.g. lecture plan) Course material (e.g. slides, exercises, notes) Check the course Web page regularly

CampusNet: Is being used to send messages;

make sure that you receive all messages from CampusNet

Books:

Textbook: Software Engineering 9 from Ian Sommerville available at Polyteknisk Boghandel Suplementary literature on the course Web page

Course Language

The course language is Danish; slides, notes, and other material mostly in English If everybody agrees to that, it can be given in English

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 5 / 94

slide-5
SLIDE 5

Introduction to Software Engineering Introduction

Software Development Problem: Building large software

You learn techniques for building skyscrapers But the projects you are doing are still only little huts

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 9 / 94

slide-6
SLIDE 6

Introduction to Software Engineering Introduction

What is software?

Software is everywhere: PC, phones, electronic devices (e.g. TV, washing machine, . . . ), computing centre, Web server, . . . Software Not only the computer program(s) but also Documentation (User–, System–) Configuration files, . . . Types of software

Mass production (like Windows, Linux, OpenOffice, SharePoint, SAP . . . ): The maker of the software owns the system specification Customised software: The customer owns the system specification Mixture: Customised software based on mass production software (e.g. workflow management systems based on SharePoint, . . . )

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 10 / 94

slide-7
SLIDE 7

Introduction to Software Engineering Introduction

Software attributes

Maintainability

Can be evolved through several releases and changes in requirements and usage

Dependability and security

Includes: reliability (robustness), security, and safety

Efficiency

Don’t waste system resources such as memory or processor cycles Responsiveness, processing time, memory utilisation

Acceptability

To the user of the system understandable, usable, and compatible with the other systems the user uses

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 11 / 94

slide-8
SLIDE 8

Introduction to Software Engineering Introduction

Software Engineering

Software Engineering Definition (Sommerville 2010) Software engineering is an engineering discipline that is concerned with all aspects of software production from the early stages of system specification through to maintaining the system after it has gone into use. An engineer

applies appropriate theories, methods, and tools Works within a set of constraints: producing the required quality within the schedule and budget → make things work

All aspects of software production: Not only writing the software but also

Software project management and creation of tools, methods and theories

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 12 / 94

slide-9
SLIDE 9

Introduction to Software Engineering Introduction

Related disciplines

Software Engineering uses Computer Science (theories and methods that underlie computers and software systems)

e.g. formal languages (e.g. parsing, compilation), computational theory and complexity theory, datastructures, . . . Knowledge of Computer Science is essential for a software engineer

System engineering (theories and methods for the development and evolution of complex systems)

e.g. physical systems, business processes, . . . Software is becoming more and more and important part of todays system

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 13 / 94

slide-10
SLIDE 10

Introduction to Software Engineering Introduction

Software Engineering diversity

Types of application (excerpt)

Stand-alone application (e.g. Word, Excel) Interactive transaction-based applications (e.g. flight booking) Embedded control systems (e.g., control software the Metro, mobile phones) Batch processing systems (e.g. salary payment systems, tax systems) Entertainment systems (e.g. Games) System for modelling and simulation (e.g. weather forecasts) Data collection and analysing software (e.g. physical data collection via sensors, but also data-mining Google searches) System of systems (e.g. cloud, system of interacting software systems)

→ Not one tool, method, or theory

Though there are general principles applicable to all domains

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 14 / 94

slide-11
SLIDE 11

Introduction to Software Engineering Introduction

Basic Activities in Software Developement

Understand and document what kind of the software the customer wants

→ Requirements Engineering

Determine how the software is to be built

→ Design

Build the software

→ Implementation

Validate that the software solves the customers problem

→ Testing → Verification → Evaluation: e.g. User friendliness

Each of these have their own methods, tools, and theories

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 15 / 94

slide-12
SLIDE 12

Introduction to Software Engineering Development Example

Example Vending Machine

The task is to implement a control software for a vending machine. The control software has to react

  • n the insertion of coins and

selecting a fruit. One should also be able to see how much money the user currently has inserted and how much of a given type of fruit is

  • left. In addition, the owner of the

vending machine should be able to see how much money currently is in the machine.

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 17 / 94

slide-13
SLIDE 13

Introduction to Software Engineering Development Example

Vending Machine: Requirements documentation

Understand and document what kind of the software the customer wants

→ Glossary → Use case diagram

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 18 / 94

slide-14
SLIDE 14

Introduction to Software Engineering Development Example

Glossary

Vending machine: The vending machine allows users to buy fruit. User: The user of the vending machine buys fruit by inserting coins into the machine. Owner: The owner owns the vending machine. He is required to refill the machine and can remove the money from the machine. Display: The display shows how much money the user has inserted. Buy fruit: Buy fruit is the process, by which the user inputs coins into the vending machine and selects a fruit by pressing a button. If enough coins have been provided the selected fruit is dispensed. Cancel: The user can cancel the process by pressing the button

  • cancel. In this case the coins he has inserted will be returned.

. . .

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 19 / 94

slide-15
SLIDE 15

Introduction to Software Engineering Development Example

Use case diagram

VendingMachine User Owner Buy Fruit Cancel Refill Machine Takeout Money

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 20 / 94

slide-16
SLIDE 16

Introduction to Software Engineering Development Example

Use Case: Buy Fruit

name: Buy fruit description: Entering coins and buying a fruit actor: user main scenario:

  • 1. Input coins until the price for the fruit to be selected is reached
  • 2. Select a fruit
  • 3. Vending machine dispenses fruit

alternative scenarios:

  • a1. User inputs more coins than necessary
  • a2. select a fruit
  • a3. Vending machine dispenses fruit
  • a4. Vending machine returns excessive coins

. . .

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 21 / 94

slide-17
SLIDE 17

Introduction to Software Engineering Development Example

Vending Machine: Specify success criteria

Prepare for the validation

→ Create tests together with the customer that show when system fulfils the customers requirements

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 22 / 94

slide-18
SLIDE 18

Introduction to Software Engineering Development Example

Functional Test for Buy Fruit Use Case: JUnit Tests

@Test public void testBuyFruitExactMoney() { VendingMachine m = new VendingMachine(10, 10); m.input(1); m.input(2); assertEquals(3, m.getCurrentMoney()); m.selectFruit(Fruit.APPLE); assertEquals(Fruit.APPLE, m.getDispensedItem()); } @Test public void testBuyFruitOverpaid() { VendingMachine m = new VendingMachine(10, 10); m.input(5); assertEquals(5, m.getCurrentMoney()); m.selectFruit(Fruit.APPLE); assertEquals(Fruit.APPLE, m.getDispensedItem()); assertEquals(2, m.getRest()); }

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 23 / 94

slide-19
SLIDE 19

Introduction to Software Engineering Development Example

Vending Machine: Design and implementation

Determine how the software is to be built

→ Class diagrams to show the structure of the system → State machines to show how the system behaves

Build the software

→ Implement the state machine using the state design pattern

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 24 / 94

slide-20
SLIDE 20

Introduction to Software Engineering Development Example

High-level Class diagram

«enumeration» Fruit APPLE BANANA VendingMachine dispensedItem: Fruit currentMoney: int totalMoney: int restMoney: int input(money: int) select(f: fruit) cancel() *

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 25 / 94

slide-21
SLIDE 21

Introduction to Software Engineering Development Example

Application logic as state machine

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 26 / 94

slide-22
SLIDE 22

Introduction to Software Engineering Development Example

Alternative representation of the application logic

event guard state state state Idle (I) banana banana

  • > B
  • > B
  • > B

banana

  • > I
  • > I
  • > I

apple apple

  • > A
  • > A
  • > A

apple

  • > I
  • > I
  • > I

money money money cancel Banana selected and not enough money (B) Apple selected and not enough money (A) enough money for banana dispense banana and rest money-> I dispense banana and rest money-> I dispense banana and rest money-> I not enough money for banana no bananas available enough money for apple dispense apple and rest money -> I dispense apple and rest money -> I dispense apple and rest money -> I not enough money for apple no apples available enough money for banana add money to current money dispense banana and rest money-> I add money to current money enough money for apple add money to current money add money to current money dispense apple and rest money -> I not enough money for neither banana nor apple add money to current money add money to current money add money to current money return current money

  • > I

return current money

  • > I

return current money

  • > I

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 27 / 94

slide-23
SLIDE 23

Introduction to Software Engineering Development Example

Design of the system as class diagram

Uses the state design pattern

«enumeration» Fruit APPLE BANANA VendingMachine dispensedItem: Fruit currentMoney: int totalMoney: int restMoney: int input(money: int) select(f: fruit) cancel() ~setIdleState() ~dispense(f: Fruit) ~setCurrentStateForFruit(f: Fruit) ~hasFruit(f: Fruit) 1 «interface» VendingMachineState input(m: VendingMachine, money: int) select(m: VendingMachinef: fruit) cancel(m: VendingMachine) IdleState input(m: VendingMachine, money: int) select(m: VendingMachinef: fruit) cancel(m: VendingMachine) FruitSelectionState input(m: VendingMachine, money: int) select(m: VendingMachinef: fruit) cancel(m: VendingMachine) 1 * m.setCurrentMoney(m.getCurrentMoney() + i); if (!m.hasFruit(fruit)) { m.setIdleState(); return; } if (m.hasEnoughMoneyFor(fruit)) { m.setIdleState(); m.dispense(fruit); } else { m.setCurrentStateForFruit(fruit); } m.dispense(null); super.input(m, i); if (m.hasEnoughMoneyFor(selectedFruit)) { m.setIdleState(); m.dispense(selectedFruit); } m.setIdleState(); super.cancel(m);

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 28 / 94

slide-24
SLIDE 24

Introduction to Software Engineering Course content

Learning objectives of the course and approach to teaching

Learning objectives

To have an overview over the field software engineering and what is required in software engineering besides programming To be able to take part in bigger software development projects To be able to communicate with other software designers about requirements, architecture, design → To be able to conduct a smaller project from an informal and open description of the problem

Approach to teaching

Providing a general overview of what makes up software engineering Teach a concrete method of doing a project (i.e. agile software development with test-driven development)

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 30 / 94

slide-25
SLIDE 25

Introduction to Software Engineering Course content

Course content

  • 0. Introduction
  • 1. Software Development Process
  • 2. Requirements Engineering
  • 3. Software Testing
  • 4. System Modelling (mainly based on UML)
  • 5. Architecture (e.g layered architecture)
  • 6. Design (among others Design Patterns)

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 31 / 94

slide-26
SLIDE 26

Software Development Process

Software Development Challenges

Challenges of Software Development

On time In budget No defects Customer satisfaction

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 33 / 94

slide-27
SLIDE 27

Software Development Process

Software Development Process

Activities in Software Development

Understand and document what kind of the software the customer wants

→ Requirements Analysis

Determine how the software is to be built

→ Design

Build the software

→ Implementation

Validate that the software solves the customers problem

→ Testing → Verification → Evaluation: e.g. User friendliness

Each of the steps has its associated set of techniques However, the techniques can be applied in different orders

→ Different software development processes e.g. Waterfall and Iterative processes (e.g. Rational Unified Process (RUP), agile processes: Extreme Programming (XP), SCRUM, Feature Driven Development, Lean . . . )

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 34 / 94

slide-28
SLIDE 28

Software Development Process

Waterfall process

Strict waterfall: An activity has to terminate (e.g. formally approved) before the next activity begins

→ No feedback possible from the later activities → Takes too long time for the system to be build, which does not allow the customer to give feedback

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 35 / 94

slide-29
SLIDE 29

Software Development Process

Waterfall

→ No feedback from the next activity possible until the next activity is approved

But: during the design of the system new questions come up on how to interpret the requirements; or during the implementation questions come up on how to interpret the design → formal (costly) change process with approval → waste (c.f. Lean software development) → Iterative development improves on that (depends on the number of iterations)

Delay in one phase of the project delays the whole project

D I T A

Time Features Release date Features

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 36 / 94

slide-30
SLIDE 30

Software Development Process

Iterative Processes: E.g. Rational Unified Process

Inception, Elaboration, Construction, Transition corresponds to Plan the project, understand the problem, build the solution, test the solution, maintain the solution

All activities occur throughout the project After each iteration, the customer sees the product and gives feedback

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 37 / 94

slide-31
SLIDE 31

Software Development Process

Agile Processes and Lean Software Development

eXtreme Programming (XP), Scrum, Feature Driven Development (FDD), Lean Software Development Iterations getting shorter than with, e.g., RUP New set of techniques: Pair programming, customer on site, user stories, test-first and test-driven development, . . . Focus on marketable features

A feature of the software that is relevant for the customer User stories (XP), Backlog (Scrum), Features (FDD), ... Corresponds roughly to use case scenarios

Lean Software Development

Apply values and principles from Lean Production to Software Development

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 38 / 94

slide-32
SLIDE 32

Software Development Process

eXtreme Programming (XP)

Defined by Kent Beck, Ward Cunningham, and others while working at Chrysler on the C3 project (a payroll system) end of the 90’s

Original project could not be finished Kent Beck was hired as a consultant and defined eXtreme Programming to finish the project

Name: take classical software engineering techniques and put them to the extreme

→ Tests are good: test always and make tests before writing the code → automatic tests and test-driven development → Code review is good: Do the code review while programming → pair programming

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 39 / 94

slide-33
SLIDE 33

Software Development Process

eXtreme Programming practices

Kent Beck, eXtreme Programming, 1st edition

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 40 / 94

slide-34
SLIDE 34

Software Development Process

eXtreme Programming Functionality Time

AD I T AD I T R AD I T R

F 1 F 2 F 3 F 4 F 5 F 6 F 7

  • 1. Iteration

Functionality

AD I T R AD I T R AD I T R

F 2 F 3 F 8 F 4 F 5 F 6

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 41 / 94

slide-35
SLIDE 35

Software Development Process

eXtreme Programming

Functionality Time

AD I T AD I T R AD I T R AD I T R AD I T R AD I T R

F 1 F 2 F 3a F 8 F 4 F 5 F 6

R AD I T

  • 1. Iteration

Iterations are planned by the customer and the developer based

  • n user stories (stories about how the system is to be used)

Customer decides on priority; Developer decides on effort: planning game → If the project is delayed, low priority features get not implemented

Important step: refactoring: Improve the design of the system without changing its functionality

Automated tests work as regression tests and ensure that existing functionality is not lost

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 42 / 94

slide-36
SLIDE 36

Software Development Process

Lean Software Development

Apply ideas from Lean production to software development

Main principle: Reduce the amount of waste (e.g. time spent that does not produce value for the customer) E.g. for waste:

time needed to fix bugs; time needed to change the system because it does not satisfies the customers requirements; waiting time for someone to approve, e.g. the design e.t.c.

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 43 / 94

slide-37
SLIDE 37

Software Development Process

Cycle time

Solution: Increase feedback by reducing the cycle time (time it takes to go one time through the process)

cycle time =

number of features feature implemantion rate

E.g. Waterfall (A,D,I,T): 1000 features, 52 weeks; feature implementation rate = 19.23 features/week cycle time = 1000 / 19.23 = 52 weeks → Feedback regarding the product and the process after 52 week

Reducing cycle time by reducing the number of features: Without changing the process, the cycle time for one feature becomes

cycle time = 1 / 19.23 = 2 hours → Feedback regarding product feature and process only 2h → Time to finish the product is the same: 1000 * 2h = 52 weeks, but customer can provide immediate feedback on the product and process improvements become possible because the same process runs 1000 times instead of just once!!

→ This provides the possibility to reduce the 52 weeks time!!

→ Generate flow

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 44 / 94

slide-38
SLIDE 38

Software Development Process

Generating flow using Pull and Kanban

A I T

Work Item Done

D

Queue WIP Queue Queue Queue WIP WIP WIP

Login

1

Composite Leaf Assembly

3

Blah

5

1 3 2 4 5

A T I D

Composite Leaf Assembly

1 1 1

Login

3 3

Composite Leaf Assembly

2

Login

4

Login

2

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 46 / 94

slide-39
SLIDE 39

Software Development Process

Software Engineering: Flow through Pull with Kanban

Process controlling: local rules Load balancing: Kanban cards and Work in Progress (WIP) limits

Figure from David Anderson www.agilemanagement.net

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 47 / 94

slide-40
SLIDE 40

Software Development Process

Example: Empire State Steel Construction

From The Empire State Building by John Tauranac From Building the Empire State by Willis, 1998

Kept the budget Was finished before deadline Built in 21 month (from conception to finished building) (1931)

→ Basic design in 4 weeks

Fast-track construction

→ Begin the construction before the design is complete → create a flow

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 48 / 94

slide-41
SLIDE 41

Software Development Process

Summary Software Development Process

There are several types of basic process models

Waterfall, Iterative Development (e.g. RUP), agile processes (eXtreme Programming, Lean software development)

Each of these process models needs to be adapted to the real situation in a company Some process models also depend on the culture of the company; e.g. XP does not work good in an environment with a strict process/document mindset While the usual saying is, different types of project need different types of projects and that agile software development is not suitable for everything, my experience shows that agile software development can be applied to a lot more project types then one thinks

The reason why one thinks it does not work is, because the decision makes have not tried it → Elements from agile processes are integrated into the exercises of this course

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 49 / 94

slide-42
SLIDE 42

Eclipse, JUnit, and Exercises

Exercise

The basic exercises for the next 7 weeks are related to the implementation of a library software Each week will have tasks related to this implementation The development will be based on agile software development principles

User-story driven: The development is done based on user stories that are implemented one by one Test-driven: Each user-story is implemented test-driven

We use JUnit as the test framework First the tests are provided by me, later you have to write your own tests You need to uncomment each test one by one (and not all at once) Use Eclipse code hints to implement missing classes/interfaces/methods

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 51 / 94

slide-43
SLIDE 43

Eclipse, JUnit, and Exercises

Eclipse code hint

Eclipse does not know the class LibraryApp and proposes to create it if one clicks on the light bulb . Make sure that the source folder ends with src and not test

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 52 / 94

slide-44
SLIDE 44

Eclipse, JUnit, and Exercises

JUnit

JUnit is designed by Kent Beck in Erich Gamma to allow to write automated tests and execute them conveniently JUnit can be used standalone, but is usually integrated in the IDE (in our case Eclipse) We are going to use JUnit version 4.x which indicates tests to be run automatically using the @org.junit.Test annotation (or just @Test if org.junit.Test is imported)

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 53 / 94

slide-45
SLIDE 45

Eclipse, JUnit, and Exercises

JUnit: Creating new Eclipse projects I

With JUnit 4.x every class can have tests by just annotating the method with @Test However, I suggest to separate tests from the source code by putting them into their own source folder This can be done either on creation time or by Using the properties dialog (selecting Java Build Path and then Source) The advantage of doing so is that tests can be put in the same package as the class to test, and thus have more access rights than they would have if they would be in a separate

  • package. And still tests are separated from production code.

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 54 / 94

slide-46
SLIDE 46

Eclipse, JUnit, and Exercises

JUnit: Creating new Eclipse projects II

In addition, the JUnit 4 libraries have to be available in the project. This can be done again in the properties dialog (selecting Java Build Path and then Libraries)

c 2010 H. Baumeister (IMM) Software Engineering I (02161) Spring 2010 55 / 94