+ All Categories
Home > Software > Top Legacy Sins

Top Legacy Sins

Date post: 16-Apr-2017
Category:
Upload: eberhard-wolff
View: 4,011 times
Download: 0 times
Share this document with a friend
81
Top Legacy Sins Eberhard Wolff Fellow @ewolff
Transcript
Page 1: Top Legacy Sins

Top Legacy SinsEberhard Wolff

Fellow@ewolff

Page 2: Top Legacy Sins

http://microservices-buch.de/ http://microservices-book.com/

Page 3: Top Legacy Sins

What should a Software Architect do?

Page 4: Top Legacy Sins

Create a Proper Architecture.

Page 5: Top Legacy Sins

Create a Proper Architecture.

Agree??

Page 6: Top Legacy Sins

I’m a Software Architect.

But I’m not doing architecture. !

Page 7: Top Legacy Sins

How important is Software

Architecture?

Page 8: Top Legacy Sins

Why would we care about Software Architecture?

Page 9: Top Legacy Sins

Software Architecture=Structure

Page 10: Top Legacy Sins

Architecture Goals: Quality

> All kinds of quality

> Performance

> Security

> …

> Focus of this presentation: Changeability

> Architects must understand customers & priority

Page 11: Top Legacy Sins

Architects must understand customer

Page 12: Top Legacy Sins

Software ArchitectureSet of

structures

comprise

software elements,

relations among them, and

properties of both.

Page 13: Top Legacy Sins

Why?

> Can work on modules in isolation

> Can work on collaboration of modules

> Fits in my head

Dan North

Page 14: Top Legacy Sins

Does He Care?

Page 15: Top Legacy Sins

Why?Great

Architecture

SoftwareEasy to change

Highproductivity

LowCost

Page 16: Top Legacy Sins

He Cares

Page 17: Top Legacy Sins

Why?Great

Architecture

SoftwareEasy to change

Highproductivity

LowCost

Page 18: Top Legacy Sins

What He Cares AboutGreat

Architecture

SoftwareEasy to change

Highproductivity

LowCost

Page 19: Top Legacy Sins

Is architecture the only factor for changeability?

Page 20: Top Legacy Sins

What is the best thing we can have in a

legacy code?

Page 21: Top Legacy Sins

Great architecture

orautomated tests?

Page 22: Top Legacy Sins

No Automated Tests

> No way to find bugs

> Changes almost impossible

> Legacy code = code without tests

> Michael FeathersWorking Effectively with Legacy Code

Page 23: Top Legacy Sins

Let’s add some automated UI tests

Page 24: Top Legacy Sins

Automated UI Tests

> Easy to implement

> Exactly what testers do manually

> Easy to understand for customers

> Test business processes

> Safety net

Page 25: Top Legacy Sins

Unit Tests

or automated UI tests?

Page 26: Top Legacy Sins

Many UI Tests Worse > Fragile: Changes to UI break test

> Business meaning of tests easily lost

> Takes long

> Often not reproducible

Page 27: Top Legacy Sins

Automated UI Tests

Automated Integration

Tests

Unit Tests

Manual Tests

Page 28: Top Legacy Sins

Automated UI Tests

Automated Integration

Tests

Unit Tests

Manual Tests

Page 29: Top Legacy Sins

SlowUnreliableExpensive

Page 30: Top Legacy Sins

Alternatives to automated UI tests?

Page 31: Top Legacy Sins

TextuellerAkzeptanztest

Page 32: Top Legacy Sins

Szenario> Möglicher Ablauf in einer Story

> Standardisierte Bestandteile:

> Gegeben... (Kontext)

> Wenn... (Ereignis)

> Dann... (erwartetes Ergebnis)

Page 33: Top Legacy Sins

Szenario: BeispielSzenario: Kunde registriert sich erfolgreich

Kontext

Ereignis

Erwartetes Ergebnis

Erwartetes Ergebnis

Gegeben ein neuer Kunde mit EMail [email protected] Vorname Eberhard Name Wolff

Wenn der Kunde sich registriert

Dann sollte ein Kunde mit der EMail [email protected] existieren

Und es sollte kein Fehler gemeldet werden

Page 34: Top Legacy Sins

RegistrationService registrationService;// Initialisierung RegistrationService// ausgelassen

private User kunde;private boolean fehler = false;

@Given("ein neuer Kunde mit "+"EMail $email Vorname $vorname"+" Name $name")public void gegebenKunde(String email,String vorname, String name) {kunde = new User(vorname, name,email);

}

Page 35: Top Legacy Sins

@When("der Kunde sich registriert")public void registerKunde() {try {

registrationService.register(kunde);} catch (IllegalArgumentException ex) {

fehler = true;}

}@Then("sollte ein Kunde mit der EMail $email existieren")public void existiert(String email) {assertNotNull(registrationService.getByEMail(email));

}@Then("es sollte kein Fehler gemeldet werden")

public void keinFehler() {assertFalse(fehler);

} }

Page 36: Top Legacy Sins

Test is about handling risk

Page 37: Top Legacy Sins

Tests for Risks> Algorithm / calculation wrong:

Unit test

> System failures:Unit tests

> Wiring / collaboration:Integration tests

> Business process:Integration test

> UI: UI test

Page 38: Top Legacy Sins

Example: User Registration

> Unit test

Validations

Database failure

> Integration test

Process

> UI test

Everything shown?

Page 39: Top Legacy Sins

Not Tested

> UI won’t test validation

> …or algorithms

> …or the process

> Risks handled elsewhere

Page 40: Top Legacy Sins

Automated UI Tests

Automated Integration

Tests

Unit Tests

Manual Tests

Page 41: Top Legacy Sins

Automated UI Tests.

Automated Integration

Tests

Unit Tests

ManualTests

Test Pyramid

Page 42: Top Legacy Sins

Test Pyramid instead of Automated UI Tests

Page 43: Top Legacy Sins

Great architecture

or fast & easy deployment?

Page 44: Top Legacy Sins

Deployment> Manual deployment is error prone

> Slow deployment

> Lots of code developed but not deployed

> i.e. more lean waste

> Slow feedback

> Slow time to recovery

Page 45: Top Legacy Sins

Leseprobe:

http://bit.ly/CD-Buch

Page 46: Top Legacy Sins

Continuous Delivery:Build Pipeline

CommitStage

AutomatedAcceptance

Testing

AutomatedCapacityTesting

ManualExplorative

TestingRelease

Page 47: Top Legacy Sins

Continuous Delivery

> Testing

> + automated deployment

> Testing: reduce probability of errors

> Automated deployment: better mean time to repair

Page 48: Top Legacy Sins

Continuous Delivery

> Make software easier to change

> & deploy

> Reliable and reproducible tests

> Automated deployed

> Fast & reliable

Page 49: Top Legacy Sins

What is a great architecture?

Page 50: Top Legacy Sins

UI

Logic

Database

Page 51: Top Legacy Sins

Is Three Tier a great architecture?

Page 52: Top Legacy Sins

Three Tier> Actually layer: no distribution

> By technology

> Layers can be replaced

> Layers can be developed independently

Page 53: Top Legacy Sins

Do you replace e.g. the persistence layer?

Page 54: Top Legacy Sins

Is it really simple to add e.g. mobile

clients?

Page 55: Top Legacy Sins

A better reason:Fits in my head.

Page 56: Top Legacy Sins

Redo the order

processing!

Page 57: Top Legacy Sins

Add feature to the

registration!

Can we change the persistence technology

instead?

Please?

Page 58: Top Legacy Sins

What is a persistence

technology??

Page 59: Top Legacy Sins

Registration Order Billing

UI

Logic

Page 60: Top Legacy Sins

Architecture> Should support changes

> …with business value

> Needs to model the domain

> Hard to get right

> Architect needs to understand the domain

Page 61: Top Legacy Sins

Is a great architecture free of cyclic

dependencies?

Page 62: Top Legacy Sins

A B

A depends on B

Changes to B influence A

Page 63: Top Legacy Sins

A B

A depends on B

Changes to B influence AB depends on A

Changes to A influence B

In fact one componentShould be two components

Page 64: Top Legacy Sins

Is a great architecture free of cyclic

dependencies?

Page 65: Top Legacy Sins

Cyclic dependencies: Architects’ Mortal Sin

Page 66: Top Legacy Sins

A B

A B

42

2

200

Page 67: Top Legacy Sins

Other Architecture Metrics

> High cohesion

> Elements of a module should belong together

> Low coupling

> Modules should not depend on each other

Page 68: Top Legacy Sins

Great Architecture

> Don’t overrate cyclic dependencies!

> Consider other metrics

> Architecture by domain

Page 69: Top Legacy Sins

The worst legacy problems?

Page 70: Top Legacy Sins

The project has a lot of cyclic

dependencies!

I know.…but that doesn’t

cause a lot of trouble

Page 71: Top Legacy Sins

Architects must understand customer

& his quality demands

Page 72: Top Legacy Sins

Quality

> Changeability

> Performance

> Security

> …

Page 73: Top Legacy Sins

No two projects are alike.

Page 74: Top Legacy Sins

No general rules.

Page 75: Top Legacy Sins

Sorry!

Page 76: Top Legacy Sins

SoftwareEasy to change

Automatedtests

Test pyramid

Fast & easy deployment

GreatArchitecture

No cyclic dependencies

Low coupling

High cohesion

Page 77: Top Legacy Sins

What should a Software Architect do?

Page 78: Top Legacy Sins

Create a Proper Architecture.

Page 79: Top Legacy Sins

Create a Proper Architecture.

Page 80: Top Legacy Sins

I’m a Software Architect.

But I’m not doing architecture.

There is more to changeable software than architecture.

Page 81: Top Legacy Sins

Thank You!@ewolff


Recommended