Slide 1

Slide 1 text

Modularisierung 4.0 Kritik der modularen Unvernunft Gernot Starke INNOQ Fellow

Slide 2

Slide 2 text

Gernot Starke INNOQ Fellow, Architektur-Verbesserer, Coach, Trainer arc42 aim42 iSAQB

Slide 3

Slide 3 text

Kritik im positiven Sinn (von Analyse) „Was kann ich wissen?“

Slide 4

Slide 4 text

„Habe Mut, dich deines eigenen Verstandes zu bedienen.“

Slide 5

Slide 5 text

Kant • ARD Mediathek: Kant für Anfänger Quelle: Wikipedia

Slide 6

Slide 6 text

Stand der Praxis • Technische Schulden • Schlechte time to market • Klotz-am-Bein

Slide 7

Slide 7 text

Ursache: Komplexität

Slide 8

Slide 8 text

Komplexität Ursache (fast) aller Übel

Slide 9

Slide 9 text

Symptome von Komplexität • Kleine Änderungen haben gravierende Konsequenzen change amplification • Sie müssen viele Details wissen cognitive load • Kein Offensichtlichkeit unknown unknowns https://disenthrall.co/complexity-is-easy/

Slide 10

Slide 10 text

Komplexität als Summe = # ∗ Teile: • Software-Komponenten • Abhängigkeiten • Notwendige Aktivitäten

Slide 11

Slide 11 text

• Änderungen aufwändig • Instabilität • Hohes Fehlerrisiko • und... Photo by NeONBRAND on Unsplash Konsequenz:

Slide 12

Slide 12 text

Abwärtsspirale Konsequenz:

Slide 13

Slide 13 text

Wie kommt‘s dazu? ...es ist doch ganz einfach...

Slide 14

Slide 14 text

Input Output Architektur Entwicklung Anforderungen Software

Slide 15

Slide 15 text

Input Output

Slide 16

Slide 16 text

Input Output ? Photo by John Cameron on Unsplash

Slide 17

Slide 17 text

Anforderungen

Slide 18

Slide 18 text

Unterschiedliche und widersprüchliche Anforderungen... • Fachbereich: Leichte Änderbarkeit • Management (1): Geringe Entwicklungskosten • Management (2): Geringe Betriebskosten • Juristen: Höchste Datensicherheit • User: Einfache Benutzbarkeit

Slide 19

Slide 19 text

Unterschiedliche und widersprüchliche Anforderungen... Anforderungen stehen in Konflikt zueinander: • Performance und Verständlichkeit • Performance und Änderbarkeit • Sicherheit und Benutzbarkeit • Robustheit und (Laufzeit-)Flexibilität

Slide 20

Slide 20 text

Wie kommt‘s dazu? ...es ist doch ganz einfach (Teil 2) ...

Slide 21

Slide 21 text

Wie kommt‘s dazu? ...es ist doch ganz einfach...

Slide 22

Slide 22 text

Software entwerfen = Verantwortung verteilen Feature neu K1 Kn Kneu

Slide 23

Slide 23 text

Der tägliche Entscheidungs-Horror... Feature neu K1 Kn Kneu Besser für Performance Besser für Security Einfacher für das Team

Slide 24

Slide 24 text

Abhilfe: Kleiner Micro

Slide 25

Slide 25 text

Modernes Prinzip: „Small is beautiful (SIB)“ SIB reduziert: • (lokale) Mengenkomplexität • Entwicklungsaufwand

Slide 26

Slide 26 text

Modernes Prinzip: „Small is beautiful (SIB)“ SIB steigert (!): • Laufzeit-Komplexität • Infrastruktur-Komplexität

Slide 27

Slide 27 text

Groß Klein Micro

Slide 28

Slide 28 text

Monolithisch Services Microservices, Self Contained Systems

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

• Unabhängig(er) entwickelbar • Geringere (lokale) Komplexität • Austauschbarkeit • Skalierbarkeit • Vorteile von Services

Slide 31

Slide 31 text

Monolithisch Services • Betriebssystem • Datenbank • App-Server • Monitoring • (Lokale) Security • Cloud-Provider Details • Cloud-Services • Datenbank • (Distributed) Security • Docker • Service Broker • Event Store • Kubernetes • Istio Service Mesh • Terraform • Verteiltes Monitoring • Log-Aggregation Erforderliches Know-How für Betrieb

Slide 32

Slide 32 text

Monolithisch Services Laufzeit nano, micro, milli, Sek, Min

Slide 33

Slide 33 text

Zeit Taktfrequenz 1 GHz -> Taktdauer 1 Nanosekunde 1 Sekunde = 1.000.000.000 Nanosekunden Licht: pro Nanosekunde 20cm

Slide 34

Slide 34 text

Zeit... 1 x klatschen entspricht 1 Nanosekunde Photo by Austin Ban on Unsplash

Slide 35

Slide 35 text

Main Memory Access (100nSec) Zähne putzen Photo: M. Zomer, https://www.pexels.com/photo/adorable-animal-animal-portrait-blur-422212/

Slide 36

Slide 36 text

Methodenaufruf (~5 Sec) Episode 1 / Staffel 1 https://www.amc.com/shows/breaking-bad

Slide 37

Slide 37 text

2kB via 1 Gbps Netzwerk senden (20Sec)

Slide 38

Slide 38 text

SSD Random Read (150 Sec) 5 Staffeln „Breaking Bad“ (ca. 36h) Photo by Alex Plesovskich on Unsplash

Slide 39

Slide 39 text

IP Roundtrip: EU – California - EU (150 mSec) https://www.hkdm.de/news-detail/news/bachelor-abschlussveranstaltung-der-hkdm-am-6-juli-2017/ Bachelor-Studium... (ca. 4.8 Jahre)

Slide 40

Slide 40 text

Zeit (Quellen) • L1 cache reference ......................... 0.5 ns • Compress 1K bytes with Zippy ............. 3,000 ns = 3 µs • Send 2K bytes over 1 Gbps network ....... 20,000 ns = 20 µs • SSD random read ........................ 150,000 ns = 150 µs • Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs • Round trip within same datacenter ...... 500,000 ns = 0.5 ms • Read 1 MB sequentially from SSD ..... 1,000,000 ns = 1 ms • Disk seek ........................... 10,000,000 ns = 10 ms • Read 1 MB sequentially from disk .... 20,000,000 ns = 20 ms • Send packet CA->Netherlands->CA .... 150,000,000 ns = 150 ms https://gist.github.com/jboner/2841832 https://dzone.com/articles/every-programmer-should-know

Slide 41

Slide 41 text

remote ist NICHT das neue local

Slide 42

Slide 42 text

Modul? Photo by Robin Glauser on Unsplash

Slide 43

Slide 43 text

Modul: • Abgeschlossene funktionale Einheit https://unsplash.com/photos/pKIsW0JS0o8

Slide 44

Slide 44 text

Modul: • Explizite Angabe von • Angebot (provided) • Bedarf (required) https://www.thomann.de/de/harley_benton_ultimate_drive.htm

Slide 45

Slide 45 text

Modul: • Trennt Schnittstelle von Implementierung

Slide 46

Slide 46 text

Prinzipien... Quelle: https://www.amazon.com/Peter-Principle-Things-Always-Wrong/dp/0062092065

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

Gelten: immer fast

Slide 49

Slide 49 text

• Lose Kopplung • Hohe Kohäsion • Geheimnisprinzip • Separation of Concerns • KISS • SOLID, DRY, YAGNI • Pfadfinder-Regel • Geltungsbereich: Kommt Drauf An KDA Prinzipien im Software-Engineering

Slide 50

Slide 50 text

KDA: Schwer!

Slide 51

Slide 51 text

Kopplung + Kohäsion

Slide 52

Slide 52 text

Kopplung und Kohäsion • Hohe Kohäsion führt zu loser Kopplung nach außen. -./ = 2 X Z Y - = 5 . = 6 / = 3

Slide 53

Slide 53 text

Lose Kopplung Hohe Kohäsion Versicherte Person Name, Vorname etc. Krankenversicherungs-Nr + Rentenversicherungs-Nr Versicherte Person Name, Vorname etc. Krankenversicherungs-Nr Rentenversicherungs-Nr

Slide 54

Slide 54 text

Lose Kopplung Hohe Kohäsion Security Versicherte Person Name, Vorname etc. Krankenversicherungs-Nr Rentenversicherte Person Rentenversicherungs-Nr

Slide 55

Slide 55 text

Kohäsion Welche Dinge gehören zusammen?

Slide 56

Slide 56 text

Welche Dinge gehören zusammen? AB X AB X CD AB CD AB CD X B X A X

Slide 57

Slide 57 text

... kommt drauf an Form... AB X AB X CD AB CD AB CD X B X A X AB X AB X CD AB CD AB CD X B X A X Farbe... Text... Größe... AB X AB X CD AB CD AB CD X B X A X AB X AB X CD AB CD AB CD X B X A X

Slide 58

Slide 58 text

Kohäsions- Anti-Pattern UDS (User Data Service) Order & Fullfillment Vouchers & Rebates Sales & Contracts Archive Price Management Marketing & Sales Campaigns Atlas Customs & Logistics Pricing Engine Sales Backend Private+Corp Sales Backend eGovernment Middleware (Message-Queue) fachliche Module Fachliche Berechnungen finden in Middleware statt...

Slide 59

Slide 59 text

Kohäsion: Anti-Pattern Module/Package Größe (KLOC) % org.foo.views 24.9 19% org.foo.controller 15.4 12% org.foo.services 3.2 2% org.foo.dto 2.2 2% org.foo.util 84.0 65% Gesamt 129.755 LoC 100%

Slide 60

Slide 60 text

Prinzipien anwenden

Slide 61

Slide 61 text

Trenne innen & außen private / public öffentlich sichtbar innere Details (Geheimnisse)

Slide 62

Slide 62 text

Trenne innen & außen private / public Java public class FXMod extends Application { public void start(Stage primaryStage) throws Exception { ... } privat Boolean validateStageBeforeDisplay(Stage stage) { ... } Go package timer type StopWatch struct { start time.Time total time.Duration running bool } func (s *StopWatch) Start() { if !s.running { s.start = time.Now() s.running = true } } func main() { clock := new(timer.StopWatch) clock.Start() if clock.running { // ILLEGAL https://yourbasic.org/golang/public-private/

Slide 63

Slide 63 text

Trenne innen & außen private / public Python >>> class Foo(object): ... __bar = 99 ... def PrintBar(self): ... print(self.__bar) >>> myFoo = Foo() >>> myFoo.__bar #does not work >>> myFoo._Foo__bar „Wäre nett, wenn...“ Python macht Einhaltung von „private“ (double-underscore) „dunders“ optional!

Slide 64

Slide 64 text

private / public genügt nicht... Java • CLASSPATH & jar Hölle • Reflection • API = alle public • import sample.*; • private: schlecht testbar https://www.funnybits.mobi/2014/08/nice-try-mom.html

Slide 65

Slide 65 text

Anti-Pattern in C++ #define private public

Slide 66

Slide 66 text

Sondern: expliziter Export öffentlich nutzbar innere Details (Geheimnisse)

Slide 67

Slide 67 text

Sondern (genauer): expliziter Export öffentlich nutzbar innere Details (Geheimnisse) innere Details (Geheimnisse) C1 C4 C2 C3 C5 C6 C7

Slide 68

Slide 68 text

Reliable Configuration: vermeidet classpath Probleme Strong Encapsulation: Modul definiert API Scalable Runtime: Ermöglicht schlankere Runtime-Images Module mit Java Jigsaw... informatik-aktuell.de/entwicklung/programmiersprachen/java-9-das-neue-modulsystem-jigsaw-tutorial.html

Slide 69

Slide 69 text

Deep, not shallow interface functionality interface functionality J.Ousterhout Niedrige „Kosten“ an Schnittstelle (kleiner == besser) Funktionalität (mehr == besser)

Slide 70

Slide 70 text

Simple interfaces •Einfach zu verstehen •Ohne Zusatzwissen nutzbar •Verbirgt innere Details •„klein“ •Verhindert Missbrauch Beispiel: Unix File I/O int open(...) size read(...) size write(...) int lseek(...) int close(...)

Slide 71

Slide 71 text

(not so) simple interface Apache PDFBox • ~ 50 Packages, • >500 Klassen, • >> 1000 public Methoden

Slide 72

Slide 72 text

Fazit (1)... Bessere Anforderungen Bessere Software www.innoq.com REQ DEV

Slide 73

Slide 73 text

Fazit (2)... Kohäsion als Schlüssel... ... zu guter Modularität www.innoq.com

Slide 74

Slide 74 text

Wägen Sie ab... Komplexität der Entwicklung Komplexität in Betrieb und Administration www.innoq.com DEV OPS

Slide 75

Slide 75 text

Danke! Fragen? Dr. Gernot Starke Gernot.Starke@innoq.com +49 177 728 2570 Krischerstr. 100 40789 Monheim am Rhein Germany +49 2173 3366-0 Ohlauer Str. 43 10999 Berlin Germany +49 2173 3366-0 Ludwigstr. 180E 63067 Offenbach Germany +49 2173 3366-0 Kreuzstr. 16 80331 München Germany +49 2173 3366-0 Hermannstrasse 13 20095 Hamburg Germany +49 2173 3366-0 Gewerbestr. 11 CH-6330 Cham Switzerland +41 41 743 0116 innoQ Deutschland GmbH innoQ Schweiz GmbH www.innoq.com