• Ingen resultater fundet

Software Engineering I (02161) Week 1 Assoc. Prof. Hubert Baumeister

N/A
N/A
Info
Hent
Protected

Academic year: 2022

Del "Software Engineering I (02161) Week 1 Assoc. Prof. Hubert Baumeister"

Copied!
44
0
0

Indlæser.... (se fuldtekst nu)

Hele teksten

(1)

Software Engineering I (02161)

Week 1

Assoc. Prof. Hubert Baumeister

DTU Compute Technical University of Denmark

Spring 2018

(2)

Contents

Course Introduction

Introduction to Software Engineering Practical Information

Programming Assignment

(3)

The course

I 5 ECTS course 02161: Software Engineering 1

I Target group: Bachelor in Software Technology and Network Technology and IT in the second semester

I Learning objectives

I Overview over software engineering: What is there more than programming?

I Learn software engineering techniques

I Communicate requirements, architecture, and design

I Do asmaller project from aninformal andopen description of the problem

(4)

Who are we?

I 117 students with different backgrounds

I Bachelor Software Technology: 73 (62%)

I Bachelor Network Technology and IT: 22 (19%)

I Other: 22 (19%)

I Teacher

I Hubert Baumeister, Assoc. Prof. at DTU Compute (huba@dtu.dk; office 303B.058)

I 3 Teaching assistants

I Sarah Dam

I Theis Kierkegaard Hauge

I Marcus Pagh

(5)

Course Language

I The course language is Danish; slides, notes, and other material mostly in English

I If everybody agrees to that, it can be given in English

(6)

Contents

Course Introduction

Introduction to Software Engineering Introduction

Development Example Practical Information Programming Assignment

(7)

What is software?

I Software is everywhere

I Desktop applications

I Web applications

I Embedded systems (IOT)

I Large batch systems

I Operatiing systems

I Big-data

I Artifical intelligence

I . . .

I Types of software

I Mass production, Customised software, Mixture of both

(8)

Types of software (Lehmann)

I s-type: mathematical function, sorting: complete specfication

I p-type: real world problems, e.g., chess: modelling the real world

I e-type: embeded into socia-technical systems.

Requirements change as the environment changes.

System changes the environment: e.g., operating system

I Continuing Change

I Increasing Complexity

I Conservation of Organisational Stability (invariant work rate)

I Continuing Growth

I Declining Quality

(9)

Success rate for software projects 2000—2008

Sheet1

Page 1

2000 2002 2004 2006 2008

succeeded 28% 34% 29% 35% 32%

failed 23% 15% 18% 19% 24%

challenged 49% 51% 53% 46% 44%

2000 2002 2004 2006 2008

0%

20%

40%

60%

80%

100%

120%

challenged failed succeeded

CHAOS Summary 2009 Report

I Succeeded: 32%

I Failed: 20%

I Challenged: 48% (over time, over budget, . . . )

Failed or challenged

I Amanda

I Rejsekortet

I Obamacare Website

I German road toll system

I Denver airport baggage system

I . . .

(10)

Scaling software development

Small hut

I one person

I no special knowledge

Skyscraper

I not possible with one person

I special knowledge: static, electricity, water, waste, elevator, . . .

(11)

Small software — large software: bug fixing

Small program

I find the defect

I fix the defect

I adjust docu- mentation

Large software

I report defect

I collect defect reports

I analyse problem

I identify bug

I define a bug fixing strategy

I fix the bug

I testing: bug fixed; no new bugs

I accept the fixed version

I integrate parallel changes

I update release documentation

I release the new system

(12)

Software attributes

I Maintainability

I Readable code (clean code, self documenting code, good documentation)

I Reduce complexity (Design Pattern, low coupling/high cohesion)

I Dependability and security

I Includes: reliability (robustness), privacy, and safety

I Example: Apple root access on macOS

I Efficiency

I Don’t waste system resources

I Responsiveness, processing time, memory utilisation

I Acceptability / user friendliness

(13)

Software attributes

I Maintainability

I Readable code (clean code, self documenting code, good documentation)

I Reduce complexity (Design Pattern, low coupling/high cohesion)

I Dependability and security

I Includes: reliability (robustness), privacy, and safety

I Example: Apple root access on macOS

I Efficiency

I Don’t waste system resources

I Responsiveness, processing time, memory utilisation

I Acceptability / user friendliness

(14)

Software attributes

I Maintainability

I Readable code (clean code, self documenting code, good documentation)

I Reduce complexity (Design Pattern, low coupling/high cohesion)

I Dependability and security

I Includes: reliability (robustness), privacy, and safety

I Example: Apple root access on macOS

I Efficiency

I Don’t waste system resources

I Responsiveness, processing time, memory utilisation

I Acceptability / user friendliness

(15)

Software attributes

I Maintainability

I Readable code (clean code, self documenting code, good documentation)

I Reduce complexity (Design Pattern, low coupling/high cohesion)

I Dependability and security

I Includes: reliability (robustness), privacy, and safety

I Example: Apple root access on macOS

I Efficiency

I Don’t waste system resources

I Responsiveness, processing time, memory utilisation

I Acceptability / user friendliness

(16)

Acceptability / user friendliness

(17)

Acceptability / user friendliness

(18)

What belongs to software?

I 10.000 LOC program, no special knowledge needed: How much time?

I Industry estimate: 24 month: around 23 LOC per work day.

I Software development is more than programming

I Validation (e.g. tests)

I Documentation (User–, System–)

I Configuration files

I . . .

(19)

What belongs to software?

I 10.000 LOC program, no special knowledge needed: How much time?

I Industry estimate: 24 month: around 23 LOC per work day.

I Software development is more than programming

I Validation (e.g. tests)

I Documentation (User–, System–)

I Configuration files

I . . .

(20)

What belongs to software?

I 10.000 LOC program, no special knowledge needed: How much time?

I Industry estimate: 24 month: around 23 LOC per work day.

I Software development is more than programming

I Validation (e.g. tests)

I Documentation (User–, System–)

I Configuration files

I . . .

(21)

Program vs product

Factor 3—20 from program to product

(22)

Software Engineering

Young disciplin: 1968 Nato conference

Software Engineering Definition (Sommerville 2010) Software engineering is anengineering disciplinethat is concerned withall aspectsofsoftware productionfrom the early stages of system specification through to maintaining the system after it has gone into use.

I Anengineer

I applies appropriate theories, methods, and tools

I All aspectsof software production:

I Not only writing the software but also

I Software project management and creation of tools, methods and theories

(23)

Basic Activities in Software Development

I Understand and document what kind of the software the customer wants (Requirements Analysis)

I Determine how the software is to be built (Design)

I Build the software (Implementation)

I Validate that the software solves the customers problem (Test)

→ Each activity has a set of techniques and methods

(24)

Software Development Process Types

Plan-driven development (Waterfall, RUP, . . . )

D I T

A

Features

Release date Time

Agile development (Extreme Programming, Scrum, . . . )

Functionality

Time

A DTI A DTI

R A DTI

R A DTI

R

A DTI R

A DTI

R

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

A DTIR

1. Iteration

(25)

Software Development Process Types

Plan-driven development (Waterfall, RUP, . . . )

D I T

A

Features

Release date Time

Agile development (Extreme Programming, Scrum, . . . )

Functionality

Time

A DTI A DTI

R A DTI

R A DTI

R

A DTI R

A DTI

R

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

A DTIR

1. Iteration

(26)

Example Vending Machine Controller

Controller software for a vending machine

(27)

Requirements: Glossary

Purpose:

I Understand the problem domain

I Common language Example

I Vending machine: The vending machine allows users to buy fruit.

I User: The user of thevending machinebuys fruit by inserting coins into the machine.

I Owner: The owner owns thevending machine. He is required to refill the machine and can remove the money from the machine.

I Display: The display shows how much money theuser has inserted.

. . .

(28)

Requirements: Use case diagram

Cancel Buy fruit Vending Machine

User

(29)

Requirements: Detailed Use Case: Buy Fruit

Feature: Buy fruit

Description: A user buys a fruit from the vending machine Actors: User

Scenario: Buy a fruit with enough money Given the vending machine has fruits

When the user enters enough money for a fruit And the user selects a fruit

Then the fruit will be dispensed And the machine returns the rest money And the machine remembers its earnings ... (More scenarios)

(30)

Validation: Specify success criteria: Acceptance tests

Use detailed use cases directly (Cucumber)

Scenario: Buy a fruit with enough money Given the vending machine has fruits

When the user enters enough money for a fruit And the user selects a fruit

Then the fruit will be dispensed

VendingMachineSteps.java

@Given("ˆthe vending machine has fruits$")

public void theVendingMachineHasFruits() throws Exception { vendingMachine = new VendingMachine(2,2);

}

@When("ˆthe user enters enough money for a fruit$")

public void theUserEntersEnoughMoneyForAFruit() throws Exception { vendingMachine.input(3);

}

@When("ˆthe user selects a fruit$")

public void theUserSelectsTheFruit() throws Exception { vendingMachine.selectFruit(Fruit.APPLE);

}

@Then("ˆthe fruit will be dispensed$")

public void theFruitWillBeDispensed() throws Exception {

assertEquals(Fruit.APPLE, vendingMachine.getDispensedItem());

}

(31)

Vending Machine: Design and implementation

I Determinehow the software is to be built

Class diagrams

Sequence diagrams

State machines

I Build the software

(32)

Design: High-level Class diagram

«enumeration»

Fruit APPLE

BANANA VendingMachine

dispensedItem: Fruit currentMoney: int totalMoney: int restMoney: int input(money: int) select(f: fruit) cancel()

*

(33)

Application logic as a state machine

event guard state state state

Idle (I)

banana

banana -> B -> B

banana -> I -> I

apple

apple -> A -> A

apple -> I -> I

money money money

cancel return current money

Banana selected and not enough money

(B)

Apple selected and not enough money

(A) enough money for

banana dispense banana and

rest money 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

(34)

Design: Design of the system as class diagram

Use State pattern (adesign 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);

} e l s e {

m.setCurrentStateForFruit(fruit);

}

m.dispense(null);

super.input(m, i);

if (m.hasEnoughMoneyFor(selectedFruit)) { m.setIdleState();

m.dispense(selectedFruit);

}

m.setIdleState();

super.cancel(m);

(35)

Design: Visualization of the Execution

I Interaction Diagrams, aka.Sequence Diagrams

I used for designing the system

I used for documenting the system

I Vending Machine

Vending Machine

select(APPLE)

select(APPLE)

hasEnoughMoney

false setCurrentState(f)

input(3)

input(3)

hasEnoughMoney true dispense(APPLE)

setIdleState

User Vending Machine i:IdleState f:FruitSelectedState

(36)

Contents

Course Introduction

Introduction to Software Engineering Practical Information

Programming Assignment

(37)

Course content

1. Requirements Engineering (Use Cases, User Stories, Glossary)

2. Software Testing (JUnit, Cucumber, Test Driven Development, Systematic Tests, Code Coverage)

3. System Modelling (Class Diagrams, Sequence Diagrams, Activity Diagrams)

4. Architecture (hexagonal, layered, . . . )

5. Design (SOLID, Design Patterns, Design by Contract, . . . ) 6. Software Development Processes (focus on agile

processes)

(38)

Software and Tools

I Programming language: Java (latest version of Java 8)

I IDE: latest version of Eclipse: Simple Java IDE is sufficient

I Test framework: Cucumber and JUnit . . .

(39)

Course activities

I Lectures every Monday 13:00 — 15:00

I Exercises after the lecture

I Teaching assistants will be present : 15:00 — 17:00

I Expected work at home:5 hours

I Important: Ask questions: during the lecture, e-mail, CampusNet, . . .

(40)

Examination

I Exam project in groups of 4

I Model, Software, Report, Demonstration

Focus on that you have learned the techniques and methods

I nowritten/oral examination

I Week 13: Demonstration of the projects (each project 10 min) and submission of final implementation

→ Grade is based on an evaluation of submissions as a whole (helheds vurdering)

(41)

Course material

I Course Web page:

http://www.imm.dtu.dk/courses/02161contains

I practical information: (e.g. lecture plan)

I Course material (e.g. slides, exercises, notes)

I Check the course Web page regularly

I CampusNet: Is being used to send messages;

I make sure that you receive all messages from CampusNet

I Books:

I Textbook: UML Distilled by Martin Fowler (online via DTU library), Software Engineering 9/10 from Ian Sommerville

I Suplementary literature on the course Web page

(42)

Contents

Course Introduction

Introduction to Software Engineering Practical Information

Programming Assignment

(43)

Programming Exercise

I Library software

I Guided development based on agile software development principles

I Behaviour-driven-development (TDD/BDD)

Eric Evans, Domain Driven Design, Addison-Wesley, 2004

1. Development of the application + domain layer

2. Presentation layer 3. Simple persistency layer

(44)

First week’s assignment

I Given use case scenarios for: Admin Login, Admin logout, Add book, and Search book

Scenario: Administrator can login

Given that the administrator is not logged in And the password is "adminadmin"

Then the administrator login succeeds And the adminstrator is logged in I And step definitions

@Given("ˆthat the administrator is not logged in$")

public void thatTheAdministratorIsNotLoggedIn() throws Exception { assertFalse(libraryApp.adminLoggedIn());

}

@Then("ˆthe administrator login succeeds$")

public void theAdministratorLoginSucceeds() throws Exception { assertTrue(libraryApp.adminLogin(password));

} ...

I Implement the production code

I Test have to pass

I Tools: Cucumber and JUnit

Referencer

RELATEREDE DOKUMENTER

Scenario: User borrows book but has already more than 10 books Given the user has borrowed 10 books. And a user is registered with the library And a book is in

Software Development Process (cont.) From Requirements to Design: CRC Cards Version control... Resource

I new velocity: story points of finished user stories per iteration. → What can be done in the

Travel Agency functional requirements: System use cases Part I: manage trip.. Travel Agency functional requirements: System use cases Part II:

Recommended (but not mandatory) Design process 1 Create glossary, use cases, and domain model 2 Create user stories based on use case scenarios. 3 Create a set of initial classes

Software Testing (JUnit, Test Driven Development, Systematic Tests, Code Coverage). System Modelling (mainly based on

Software Testing (JUnit, Test Driven Development, Systematic Tests, Code Coverage). System Modelling (mainly based on

Scenario: User borrows book more than 10 books Given a registered user has borrowed 10 books When the user borrows another book. Then the book is not borrowed by