Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the...

48
Refactoring of Large Software Systems revised

Transcript of Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the...

Page 1: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Refactoring of Large Software Systems revised

Page 2: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 2

Sibylle Peter Sven Ehrke

Page 3: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 3

> Introduction

> The Case Study: Advisory Tool for Investment Bankers

> The Refactoring

> The Way We Work

> Lessons Learned

Page 4: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Introduction

Page 5: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 5

Definit ion (Mart in Fowler, Refactoring, pg. 53):

Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behavior.

Refactor (verb): To restructure software by applying a series of refactorings without changing it ‘s observable behavior

Page 6: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 6

Page 7: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 7

Page 8: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 8

Page 9: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 9

Page 10: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 10

Page 11: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

The Case Study

Page 12: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 12

Page 13: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 13

Facts

> Productive and successful since 2004

> Continuously expanded/ enlarged since then

> 320 JSP, 1800 classes

> Homegrown MVC framework, similar to Struts

> ca. 70 functional tests

> Few unit tests

> Little documentation

> High employee turnover

> High maintenance costs

> Change requests cannot be implemented

– complex ity

– Side effects

Page 14: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 14

Dependencies

Page 15: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 15

Original Situation

Action

Java Beans

JSP

ServiceInvoker

Service

Worker

Controller Helper

Mapper

Container

HttpServlet

BusinessObject

HttpServlet

Page 16: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 16

Action

Java Beans

JSP

Container

HttpServlet

BusinessObject

Facade TransferObject

HttpServlet

Util

Masterplan

Service Mapper

Page 17: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 17

Java Beans

Service Mapper

Validator

Facade TransferObject

Action

JSPHttpServlet

Masterplan

Formatter

AggregatingFacade

Standard GUIStandard GUITechnologyTechnology

(TBD)(TBD)

Page 18: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

The RefactoringPart I – new service layer

Page 19: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 19

Service Layer Architecture

Presentation Layer

ServiceLayer

aggregation

Facade 1 Facade 2 Facade 3 Facade 4

WS DB Host

Facade 2Facade 1

Serv

icel

ayer

.uti

l

Page 20: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 20

Step 1: Structuring through Facades

Page 21: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 21

Step 2: Introducing Transfer Objects

Page 22: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 22

PresentationLayer

transfer objects

JSP Java Bean Action HttpRequest

BusinessObjectConverter

TransferObject

Facade

Service

ServiceLayer

Page 23: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 23

Page 24: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 24

Page 25: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 25

Facade Interface

Page 26: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 26

PresentationLayerJSP Java Bean Action HttpRequest

BusinessObject Converter

TransferObject ServiceLayer

ServiceObject

EJB Proxy

simple

complex

1:1

1:n Mapper

Page 27: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 27

PresentationLayerJSP Java Bean Action HttpRequest

BusinessObject Converter

TransferObject ServiceLayer

ServiceObject

EJB Proxy

simple

complex

m:n

1:1 Mapper

Page 28: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 28

Step 3: New Service Layer

inTO outTO

Service

Page 29: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 29

Service Interface

Page 30: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 30

Step 3: New Service Layer

inTO outTO

Service

outSOinSO

EJB Method

Mapper Mapper

Page 31: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 31

AbstractService

Page 32: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 32

Page 33: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 33

inTO outTO

Services

inTO A outTO A

Service A

Service

inTO B outTO B

Service B

Page 34: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 34

Page 35: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 35

Step 4: Introducing Basetypes

Page 36: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 36

Facade Interface

Page 37: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

The Way We Work

Page 38: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 38

Daily Work

Page 39: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 39

Coordination

Daily standup meeting

Regular workshops with the customer‘s lead engineer

retrospective after each

refactoring step

Lightweigth, but intensive

testing process with test team

Monthly meeting with

the project manager of the

customer

Weekly reporting with

the lead engineer and

team lead of the customer

Page 40: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 40

Without changing it’s observable behavior

Functional tests

> 50% code coverage

Continuous integration

> No build server - > installed teamcity on a spare machine

> Nightly build incl. Webtests

Testing

> Functional tests require host services stubs will be created in part 2> Complete test of the application takes 3 weeks Tester integrated in our team for testing phase. > Nightly deployment on test server> Tester created videos (for us and to create more automated tests)

Page 41: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Lessons Learned

Copyright Canoo Engineering AG, www.canoo.com 41

Page 42: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 42Le

sso

ns

lear

ned

> Knowledge transfer to the core team as early as possible

> Continous integration is a must

> Investment in automated test suite

> Dependencies to other systems

> Automated quality assurance

> Testing phase much longer than anticipated

> Focus on technical refactoring can be lifesaving

> Refactoring of a large software system is a new project

> KISS: Simplicity is needed

Page 43: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 43A

chie

vem

ents

> Costs per feature reduced

> Service oriented architecture

> Side effects removed

> Separation between layers and modules

> Automated quality assurance

> Long required new functionality which served as key differentiator has been implemented

Page 44: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 44

Refactoring Benefits

Page 45: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 45

Refactoring of Large Software Systems is

Page 46: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Copyright Canoo Engineering AG, www.canoo.com 46

Refactoring of Large Software Systems needs

Page 47: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Books

• Martin Fowler, Refactoring: Improving the Design of Existing Code

• Stephan Ducasse, Oscar Nierstrasz, Object Oriented Reengineering Patterns PDF: http:/ / www.win.ua.ac.be/ ~sdemey/

Joshua Kerievsky, Refactoring to Patterns•

Martin Lippert, Stefan Rook, Refactoring in Large Software Projects

Copyright Canoo Engineering AG, www.canoo.com 47

Page 48: Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify

Questions?