76
Legacy Sins Eberhard Wolff Freelancer

Legacy Sins

Embed Size (px)

Citation preview

Page 1: Legacy Sins

Legacy Sins

Eberhard Wolff Freelancer

Page 2: Legacy Sins

Eberhard Wolff - @ewolff

I’m a Software Architect. But I’m not doing architecture. !

Page 3: Legacy Sins

Eberhard Wolff - @ewolff

How important is Software

Architecture?

Page 4: Legacy Sins

Eberhard Wolff - @ewolff

Why would we care about Software

Architecture?

Page 5: Legacy Sins

Eberhard Wolff - @ewolff

Software Architecture =Structure

Page 6: Legacy Sins

Eberhard Wolff - @ewolff

Architecture Goals: Quality•  All kinds of quality •  Performance •  Security •  … •  Focus of this presentation:

Changeability •  Architects must understand

customers & priority

Page 7: Legacy Sins

Eberhard Wolff - @ewolff

Architects must understand customer

Page 8: Legacy Sins

Eberhard Wolff - @ewolff

Software ArchitectureSet of

structures comprise

software elements, relations among them, and

properties of both.

Page 9: Legacy Sins

Eberhard Wolff - @ewolff

Why? •  Can work on modules in isolation •  Can work on collaboration of

modules

•  Fits in my head •  Dan North

Page 10: Legacy Sins

Eberhard Wolff - @ewolff

Does He Care?

Page 11: Legacy Sins

Eberhard Wolff - @ewolff

Why?Great

Architecture

Software Easy to change

High productivity

Low Cost

Page 12: Legacy Sins

Eberhard Wolff - @ewolff

He Cares

Page 13: Legacy Sins

Eberhard Wolff - @ewolff

Why?Great

Architecture

Software Easy to change

High productivity

Low Cost

Page 14: Legacy Sins

Eberhard Wolff - @ewolff

What He Cares AboutGreat

Architecture

Software Easy to change

High productivity

Low Cost

Page 15: Legacy Sins

Eberhard Wolff - @ewolff

Is architecture the only factor

for changeability?

Page 16: Legacy Sins

Eberhard Wolff - @ewolff

What is the worst thing

we can have in a legacy code?

Page 17: Legacy Sins

Eberhard Wolff - @ewolff

Great architecture

orautomated

tests?

Page 18: Legacy Sins

Eberhard Wolff - @ewolff

No Automated Tests Worse•  No way to find bugs •  Changes almost impossible

•  Legacy code = code without tests •  Michael Feathers

Working Effectively with Legacy Code

Page 19: Legacy Sins

Eberhard Wolff - @ewolff

Let’s add some

automated GUI tests

Page 20: Legacy Sins

Eberhard Wolff - @ewolff

Automated GUI Tests•  Easy to implement •  Exactly what testers do manually •  Easy to understand for customers •  Test business processes •  Safety net

Page 21: Legacy Sins

Eberhard Wolff - @ewolff

Unit Tests

or automated GUI tests?

Page 22: Legacy Sins

Eberhard Wolff - @ewolff

Many GUI Tests Worse •  Fragile: Changes to GUI break test

•  Business meaning of tests easily lost

•  Takes long

•  Often not reproducible

Page 23: Legacy Sins

Eberhard Wolff - @ewolff

Automated GUI Tests

Automated Integration

Tests

Unit Tests

Manual Tests

Page 24: Legacy Sins

Eberhard Wolff - @ewolff

Automated GUI Tests

Automated Integration

Tests

Unit Tests

Manual Tests

Page 25: Legacy Sins

Eberhard Wolff - @ewolff

SlowUnreliableExpensive

Page 26: Legacy Sins

Eberhard Wolff - @ewolff

Alternatives to automated GUI tests?

Page 27: Legacy Sins

Eberhard Wolff - @ewolff

Textueller Akzeptanztest

Page 28: Legacy Sins

Eberhard Wolff - @ewolff

Szenario•  Möglicher Ablauf in einer Story

•  Standardisierte Bestandteile: •  Gegeben... (Kontext) •  Wenn... (Ereignis) •  Dann... (erwartetes Ergebnis)

Page 29: Legacy Sins

Eberhard Wolff - @ewolff

Szenario: BeispielSzenario: Kunde registriert sich erfolgreich 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

Kontext

Ereignis

Erwartetes Ergebnis

Erwartetes Ergebnis

Page 30: Legacy Sins

Eberhard Wolff - @ewolff

public class UserRegistrationSteps {   private RegistrationService registrationService; private User kunde; private boolean fehler = false;   // Initialisierung des RegistrationService ausgelassen @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 31: Legacy Sins

Eberhard Wolff - @ewolff

@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 32: Legacy Sins

Eberhard Wolff - @ewolff

Test is about handling risk

Page 33: Legacy Sins

Eberhard Wolff - @ewolff

Tests for Risks•  Algorithm / calculation wrong:

Unit test •  System failures: Unit tests •  Wiring / collaboration:

Integration tests •  Business process: Integration test •  GUI: GUI test

Page 34: Legacy Sins

Eberhard Wolff - @ewolff

Example: User Registration•  Unit test Validations Database failure •  Integration test Process •  GUI test Everything displayed?

Page 35: Legacy Sins

Eberhard Wolff - @ewolff

Not Tested•  GUI won’t test validation •  …or algorithms •  …or the process

•  Risks handled elsewhere

Page 36: Legacy Sins

Eberhard Wolff - @ewolff

Automated GUI Tests

Automated Integration

Tests

Unit Tests

Manual Tests

Page 37: Legacy Sins

Eberhard Wolff - @ewolff

Automated GUI Tests.

Automated Integration

Tests

Unit Tests

Manual Tests

Test Pyramid

Page 38: Legacy Sins

Eberhard Wolff - @ewolff

Test Pyramid instead of Automated GUI tests

Page 39: Legacy Sins

Eberhard Wolff - @ewolff

Great architecture

or fast & easy deployment?

Page 40: Legacy Sins

Eberhard Wolff - @ewolff

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 41: Legacy Sins

Eberhard Wolff - @ewolff

Leseprobe: http://bit.ly/CD-Buch

Page 42: Legacy Sins

Eberhard Wolff - @ewolff

Continuous Delivery: Build Pipeline

Commit Stage

Automated Acceptance

Testing

Automated Capacity Testing

Manual Explorative

Testing

Release

Page 43: Legacy Sins

Eberhard Wolff - @ewolff

Continuous Delivery•  Testing •  + automated deployment

•  Testing: reduce probability of errors •  Automated deployment: better

mean time to repair

Page 44: Legacy Sins

Eberhard Wolff - @ewolff

Continuous Delivery•  Make software easier to change •  & deploy

•  Reliable and reproducible tests •  Automated deployed •  Fast & reliable

Page 45: Legacy Sins

Eberhard Wolff - @ewolff

What is a great architecture?

Page 46: Legacy Sins

Eberhard Wolff - @ewolff

GUI

Logic

Database

Page 47: Legacy Sins

Eberhard Wolff - @ewolff

Is 3 Tier a great

architecture?

Page 48: Legacy Sins

Eberhard Wolff - @ewolff

3 Tier•  Actually layer: no distribution •  By technology

•  Layers can be replaced

•  Layers can be developed independently

Page 49: Legacy Sins

Eberhard Wolff - @ewolff

Do you replace e.g. the

persistence layer?

Page 50: Legacy Sins

Eberhard Wolff - @ewolff

Is it really simple to add e.g. mobile

clients?

Page 51: Legacy Sins

Eberhard Wolff - @ewolff

A better reason:

Fits in my head.

Page 52: Legacy Sins

Eberhard Wolff - @ewolff

Redo the order

processing!

Page 53: Legacy Sins

Eberhard Wolff - @ewolff

Add this to the

registration!

Page 54: Legacy Sins

Eberhard Wolff - @ewolff

Can we change the

persistence technology

instead?

Page 55: Legacy Sins

Eberhard Wolff - @ewolff

Please

Page 56: Legacy Sins

Eberhard Wolff - @ewolff

What is a persistence

technology??

Page 57: Legacy Sins

Eberhard Wolff - @ewolff

Registration Order Billing

GUI

Logic

Page 58: Legacy Sins

Eberhard Wolff - @ewolff

Architecture•  Should support changes •  …with business value •  Needs to model the domain •  Hard to get right •  Architect needs to understand the

domain

Page 59: Legacy Sins

Eberhard Wolff - @ewolff

Is a great architecture free of cyclic

dependencies?

Page 60: Legacy Sins

Eberhard Wolff - @ewolff

A B

A depends on B

Changes to B influence A

Page 61: Legacy Sins

Eberhard Wolff - @ewolff

A B

A depends on B

Changes to B influence A B depends on A

Changes to A influence B

In fact one component Should be two components

Page 62: Legacy Sins

Eberhard Wolff - @ewolff

Is a great architecture free of cyclic

dependencies?

Page 63: Legacy Sins

Eberhard Wolff - @ewolff

Cyclic dependencies:

architects’ mortal sin

Page 64: Legacy Sins

Eberhard Wolff - @ewolff

A B

A B

42

2

200

Page 65: Legacy Sins

Eberhard Wolff - @ewolff

Other Architecture Metrics•  High cohesion Elements of a module should belong together •  Low coupling Modules should not depend on each other

Page 66: Legacy Sins

Eberhard Wolff - @ewolff

Great Architecture•  Don’t overrate cyclic dependencies!

•  Consider other metrics

•  Architecture by domain

Page 67: Legacy Sins

Eberhard Wolff - @ewolff

The worst legacy

problems?

Page 68: Legacy Sins

Eberhard Wolff - @ewolff

The project has a lot of cyclic dependencies!

I know. …but that doesn’t cause a lot of trouble

Page 69: Legacy Sins

Eberhard Wolff - @ewolff

Architects must understand

customer & his quality demands

Page 70: Legacy Sins

Eberhard Wolff - @ewolff

Quality•  Changeability •  Performance •  Security •  …

Page 71: Legacy Sins

Eberhard Wolff - @ewolff

No two projects are

alike.

Page 72: Legacy Sins

Eberhard Wolff - @ewolff

No general rules.

Page 73: Legacy Sins

Eberhard Wolff - @ewolff

Sorry!

Page 74: Legacy Sins

Eberhard Wolff - @ewolff

Software Easy to change

Automated tests

Test pyramid

Fast & easy deployment

Great Architecture

No cyclic dependencies

Low coupling

High cohesion

Page 75: Legacy Sins

Eberhard Wolff - @ewolff

I’m a Software Architect. But I’m not doing architecture.

There is more to changeable software than architecture.

Page 76: Legacy Sins

Eberhard Wolff - @ewolff

Thank You!