Slide 1

Slide 1 text

Continuous Delivery für Legacy Code Richard Gross @arghrich

Slide 2

Slide 2 text

Grundlage 09.11.18 Richard Gross @arghrich 2 Richard Software Archäologe Audits Sanierungsprojekte Der schlimmste Legacy Code den ich je gesehen habe

Slide 3

Slide 3 text

Dylan Beattie @dylanbeattie Legacy Code is code that’s too scary to update and too profitable to delete. Michael Feathers @mfeathers Legacy Code is code without tests. 09.11.18 Richard Gross @arghrich 3

Slide 4

Slide 4 text

Legacy Code is code that’s too scary to update and too profitable to delete. Continuous Delivery If somebody thinks of a good idea, how do we [make it feasable to] deliver it to users as quickly as possibly? 09.11.18 Richard Gross @arghrich 4 Dylan Beattie @dylanbeattie

Slide 5

Slide 5 text

Local Env Source Repository Artifact Repository Commit Stage Acceptance Manual Test Env … Staging Env Prod Env Self-Service Automatic Dave Farley - Optimising Continuous Delivery CD Pipeline

Slide 6

Slide 6 text

CD Principles Four Principles of Low-Risk Software Releases by Jez Humble • Low-Risk Releases Are Incremental • Decouple Deployment and Release • Focus on Reducing Batch Size • Optimize for Resilience

Slide 7

Slide 7 text

09.11.18 Richard Gross @arghrich 8 Legacy Code 1 Delivery für 2 Continuous 3

Slide 8

Slide 8 text

09.11.18 Richard Gross @arghrich 9 Legacy Code 1 Delivery für 2 Continuous 3

Slide 9

Slide 9 text

09.11.18 Richard Gross @arghrich 10 Legacy Code 1

Slide 10

Slide 10 text

Ambitionierte Ziele 09.11.18 Richard Gross @arghrich 11 Alter Dienstleister (40 Personen) Delayed, Buggy releases 15y Development Neuer Dienstleister (10 Personen) =unser Kunde Quality Releases New Features … 10x On-Premise … 10x Azure Cloud

Slide 11

Slide 11 text

5M 4M LoC Lieferung 09.11.18 Richard Gross @arghrich 12 T-SQL JavaScript VBA C# Asp.NET + C# Classic Asp + VBScript Excel WinForms + C# Fat Client Webservice Database Kein Code geliefert MIA Jobs Website

Slide 12

Slide 12 text

Unsichtbare Aufrufe 09.11.18 Richard Gross @arghrich 13 Excel Webservice Website Fat Client Jobs C C C Database C C C C C (BL in) UI / API C BL DB T P T

Slide 13

Slide 13 text

10 Kundeninstallationen 09.11.18 Richard Gross @arghrich 14 Frobozz Co. Oceanic Airlines … Umbrella Corp Soylent Corp

Slide 14

Slide 14 text

… Oceanic Airlines Soylent Corp 10x Softwarestände 09.11.18 Richard Gross @arghrich 15 Frobozz Co. Umbrella Corp Gleich C/P Copy/ Paste Feature Copy/Paste

Slide 15

Slide 15 text

10x Softwarestände 10x DbSchemata 09.11.18 Richard Gross @arghrich 16 Gleich Gleich

Slide 16

Slide 16 text

Oh Boy 09.11.18 Richard Gross @arghrich 17

Slide 17

Slide 17 text

Burn It!!! 09.11.18 Richard Gross @arghrich 18

Slide 18

Slide 18 text

Burn It!!! Stop Big Bang Rewrites The True Cost of Rewrites Features Releases over time Catch Up Missing Features Sub-Par Parity Enhancements Planned Rewrite Actual Features Undiscovered Scope Old App Adoption

Slide 19

Slide 19 text

09.11.18 Richard Gross @arghrich 20 Legacy Code 1 Delivery für 2 Empfehlungen für Team & Vorgehen

Slide 20

Slide 20 text

Signifikante Veränderung im Team und in der Kultur notwendig 09.11.18 21 Richard Gross @arghrich

Slide 21

Slide 21 text

09.11.18 Richard Gross @arghrich 22 Henrik Kniberg @henrikkniberg Culture is the sum of everyone's attitude and actions, so model the behaviour you want to see! Also Verhalten beobachten: • Existiert Angst vor Fehlern? • Wie wird deployed? • Gibt es ein Qualitätsverständnis? • Will das Team dazulernen? • Wie handelt das Management? • uvm.

Slide 22

Slide 22 text

Neues Co-located Cross-functional Team mit gemeinsamen Ziel 09.11.18 23 DEV TEST OPS Endkunde

Slide 23

Slide 23 text

09.11.18 24 DEV TEST OPS Endkunde Collective Legacy, Test, Product Ownership

Slide 24

Slide 24 text

Version Everything Sollte man nicht sagen müssen, aber leider gilt: • Code – oft nicht versioniert • Config – sehr selten • Deploymentscripte – Fast nie • Infrastruktur - Nie 09.11.18 Richard Gross @arghrich 25

Slide 25

Slide 25 text

Anti-Pattern: Append-only Coding Wo muss das Feature rein: • Mein Code? if(…){ // old code } else { // new code } • Anderer Code? Copy File Planner.asp & Modify MyPlanner.asp 09.11.18 Richard Gross @arghrich 26

Slide 26

Slide 26 text

Anti-Pattern: Folder Version 09.11.18 Richard Gross @arghrich 27

Slide 27

Slide 27 text

Anti-Pattern: File Version 09.11.18 Richard Gross @arghrich 28

Slide 28

Slide 28 text

Delivery: 6 Team Tätigkeiten 09.11.18 Richard Gross @arghrich 29 (A) Vollständige Lieferung Verifizieren (C) Konfigurier- barkeit herstellen (D) Archäologie (E) Sanierung (F) Weiter- entwicklung (B) Infrastruktur aufbauen

Slide 29

Slide 29 text

(B) Infrastruktur • Dev/Prod-Parity • Phoenix Server • Jeder Build ist potentielles Release • Unternehmen vom Mehrwert von Infrastructure Automation überzeugen • Standard IA-Tools nutzen • Nicht: Ansible nachbauen mit Powershell Scripten 09.11.18 Richard Gross @arghrich 30

Slide 30

Slide 30 text

(C) Konfigurierbarkeit •Eine konfigurierbare Software, nicht 10 fest-verdrahtete •z.B.: msdeploy.exe, sqlpackage.exe • (String) replacement bei publish • Umgebungsvariablen 09.11.18 Richard Gross @arghrich 31

Slide 31

Slide 31 text

Anti-Pattern: Branch by Obscurity • Branch by (Un) Comment • Branch by Entity-Id 09.11.18 Richard Gross @arghrich 32

Slide 32

Slide 32 text

(D) Archäologie https://fs.blog/2013/07/the-difference-between-science-and-engineering/ Archeological Inquiry

Slide 33

Slide 33 text

Lernen mit Inverse Object Mother • Anwendung Starten mit leerer Datenbank und ohne Domain Modell • UseCase klicken • Fehler analysieren • Domain Modell erweitern um Erkenntnis • Benötigten Zustand in DB mit Modell herstellen • Dokumentieren als Test • Repeat 09.11.18 Richard Gross @arghrich 34

Slide 34

Slide 34 text

Inverse BDD ist schwierig • „Gegeben keine Ahnung“ • „Wenn ich hier drücke“ • „Dann kommt da hinten ein Maulwurf raus“ • Super, dass automatisieren wir jetzt … • Gherkin wird für Data-Scripting missbraucht • BDD braucht: Was will wollte der Anwender? 09.11.18 Richard Gross @arghrich 35

Slide 35

Slide 35 text

(E) Sanierung Prio 1Technisch und/oder fachlich obsoleten Code entfernen 09.11.18 Richard Gross @arghrich 36

Slide 36

Slide 36 text

Obsoleten Code finden • Anwenderumfragen • IDE gibt Vorschläge • grep auf FROM, JOIN, INSERT, UPDATE, DELETE und rein in Excel • Analytics / Activity-Log für Seiten einbauen • Legacy Toggles • Vergessen Teile zu deployen 09.11.18 Richard Gross @arghrich 37

Slide 37

Slide 37 text

Startpunkt festlegen • Linter • Profiler • CodeMaat https://github.com/ adamtornhill/code-maat • Structure101 http://structure101.com/ • SonarQube https://www.sonarqube.org/ • CodeCharta https://github.com/ MaibornWolff/codecharta Art by Zaufishan

Slide 38

Slide 38 text

Startpunkt festlegen • Linter • Profiler • CodeMaat https://github.com/ adamtornhill/code-maat • Structure101 http://structure101.com/ • SonarQube https://www.sonarqube.org/ • CodeCharta https://github.com/ MaibornWolff/codecharta 09.11.18 Richard Gross @arghrich 39

Slide 39

Slide 39 text

Golden Master für Refactoring 09.11.18 Richard Gross @arghrich 40 Saniertes System Legacy System Input for UI/API/DB Output Output Compare

Slide 40

Slide 40 text

Branching Strategy for Refactoring • Don‘t Branch • Don‘t Branch • Don‘t Branch •That‘s Ci =Continuous Isolation Strategy by Dave Farley 09.11.18 Richard Gross @arghrich 41

Slide 41

Slide 41 text

Connascence als Refactoringhilfe 2 elements A,B are connascent if there is at least 1 possible change to A requires a change to B in order to maintain overall correctness Jim Weirich‘s “Grand Unified Theory of Software Development” J Meilir Page-Jones

Slide 42

Slide 42 text

Connascence of Meilir Page-Jones | Jim Weirich‘s “Grand Unified Theory of Software Development” J • Identity • Value • Timing • Execution order • Algorithm • Position • Meaning • Type • Name Strong Weak Refactor this way

Slide 43

Slide 43 text

3-axes of Connascence Strength Level How explicit Locality How close Degree Number of Impacts Meilir Page-Jones | Jim Weirich‘s “Grand Unified Theory of Software Development” J

Slide 44

Slide 44 text

Refactoring Big Ball of Mud Isolate • Stable von Unstable • R/W mit Fassaden trennen • Interfaces • Dependency Injection • Table Views Small • Baby Steps • Feathers Techniken • Mob Programming 09.11.18 Richard Gross @arghrich 45 • Branch by abstraction • Parallel Change • Strangler Application Big

Slide 45

Slide 45 text

Use Strangler Application for big & new features https://paulhammant.com/2013/07/14/legacy-application-strangulation-case-studies/

Slide 46

Slide 46 text

09.11.18 Richard Gross @arghrich 47 Legacy Code 1 Delivery für 2 Continuous 3

Slide 47

Slide 47 text

Legacy Delivery 09.11.18 Richard Gross @arghrich 48 • Minimum Time to UAT/Prod 10min 10 minutes for Build • Regular Time to UAT 50min 10: Build | 20: DB Migrate INT | 20: DB Migrate STAGE • Nightly Infrastructure Updates 2h 30: Powershell | 60: DB Create + Init | 20: DB Migrate • Canary Builds & Releases wären besser • Alle 2 Wochen 1 Tag manuelle Testphase • Perspektivisch durch mehr E2E ersetzen

Slide 48

Slide 48 text

Lohnt sich das? • Anwender hatten aufgegeben à wir gehen Bugs auch nach • Stabiler als jemals zuvor • Niemand weiß was „so wie bisher“ bedeutet à wie soll man das neu bauen? • Hätte man auch mit Anforderungen nicht in einem Jahr neu bauen können • Fließender (Dienstleister-)Übergang à min. Feature Freeze 09.11.18 Richard Gross @arghrich 49

Slide 49

Slide 49 text

CD für Legacy Tätigkeiten • (A) Lieferung • (B) Infrastruktur • (C) Konfigurierbarkeit • (D) Archäologie • (E) Sanierung • (F) Weiterentwicklung Erfolgsfaktoren • Mut • Team • Mut zum Mob • Infra.-Automation • Pipeline • Connascence • Strangler Application 09.11.18 Richard Gross @arghrich 50

Slide 50

Slide 50 text

Ken Mugrage @kmugrage It‘s not CD if you can‘t deploy to production right now 09.11.18 Richard Gross @arghrich 51

Slide 51

Slide 51 text

Done Fragen, Anmerkungen, Mitleid? J 30 Mio 410 Mitarbeiter*innen 9. Jahr 23 Nationen 300 Wochen München, Augsburg, Berlin, Frankfurt

Slide 52

Slide 52 text

Reading • https://trello.com/b/Fdd876S8/continuous- delivery-checklist-template • Uvm. • Ich hätte nicht gedacht, dass ich diese Folie zeigen werde 09.11.18 Richard Gross @arghrich 53

Slide 53

Slide 53 text

Connascence of Meilir Page-Jones | Jim Weirich‘s “Grand Unified Theory of Software Development” J • Name: variable, method, SQL Table • Type: int, String, Money, Person • Meaning: what is true,‘YES‘,null,love • Position: order of value • Algorithm: encoding, SPA vs Server • Execution (order): one before other • Timing: doFoo() in 500ms | doBar() in 400ms • Value: constraints on value, invariants • Identity: reference same entity Weak Strong Static Dynamic