Slide 1

Slide 1 text

@el_stoffel SymfonyLive Berlin 2019 Meine ehrliche Symfony Anwendung

Slide 2

Slide 2 text

@el_stoffel SymfonyLive Berlin 2019 Was bedeutet "ehrliche Anwendung"? Realismus Hype-Driven-Development Komplexität Pragmatismus Flexibilität Stabilität Wartbarkeit vermeiden maßvolle

Slide 3

Slide 3 text

@el_stoffel SymfonyLive Berlin 2019 Wer bin ich?

Slide 4

Slide 4 text

@el_stoffel SymfonyLive Berlin 2019 Christopher Hertel Consultant & Trainer @ SensioLabs in Berlin Symfony & Twig Certified Developer iSAQB Certified Software Architect @el_stoffel Symfony User Group Berlin

Slide 5

Slide 5 text

@el_stoffel SymfonyLive Berlin 2019 • 4 Jahre • 10 PHP-/Symfony-Projekte • 800.000 LLOC • 40 Trainings & Workshops • 75 + 300 Entwickler*innen

Slide 6

Slide 6 text

@el_stoffel SymfonyLive Berlin 2019 Konzept Umsetzung Prozess Team Software Entwicklung Software Architektur Workshops OOP & Clean Code Best Practices Pair Programming Testing Dokumentation Code Review Trainings Wissenstransfer Continuous Deployment Turnover Onboarding

Slide 7

Slide 7 text

@el_stoffel SymfonyLive Berlin 2019 Was bedeutet "ehrliche Anwendung"? Realismus Hype-Driven-Development Komplexität Pragmatismus Flexibilität Stabilität Wartbarkeit vermeiden maßvolle

Slide 8

Slide 8 text

@el_stoffel SymfonyLive Berlin 2019 Agenda • Struktur der Anwendung • Software Architektur • Testing • Prozess Typische Fallstricke Best Practices

Slide 9

Slide 9 text

@el_stoffel SymfonyLive Berlin 2019 Struktur der Anwendung

Slide 10

Slide 10 text

@el_stoffel SymfonyLive Berlin 2019 Konzept Umsetzung Prozess Team Software Entwicklung Software Architektur Workshops OOP & Clean Code Best Practices Pair Programming Testing Dokumentation Code Review Trainings Wissenstransfer Continuous Deployment Turnover Onboarding

Slide 11

Slide 11 text

@el_stoffel SymfonyLive Berlin 2019 Struktur der Anwendung $ git clone ... Repositories

Slide 12

Slide 12 text

@el_stoffel SymfonyLive Berlin 2019 Struktur der Anwendung application docker project Repository Repository Repositories

Slide 13

Slide 13 text

@el_stoffel SymfonyLive Berlin 2019 Struktur der Anwendung application docker lib-x lib-y project Repository Repository Repository Repository Repositories

Slide 14

Slide 14 text

@el_stoffel SymfonyLive Berlin 2019 Struktur der Anwendung application docker lib-x lib-y project Repository Go Monorepo.org Repositories

Slide 15

Slide 15 text

@el_stoffel SymfonyLive Berlin 2019 Struktur der Anwendung • Versionierung & Autorisierung • keine Trennung von Anwendungsteilen • vermeidet Git-Puzzles • Go Monorepo Developer Experience Repositories

Slide 16

Slide 16 text

@el_stoffel SymfonyLive Berlin 2019 Struktur der Anwendung $ bin/console generate:bundle DEPRECATED Bundles

Slide 17

Slide 17 text

@el_stoffel SymfonyLive Berlin 2019 Struktur der Anwendung ApiBundle CoreBundle ExportBundle InfrastructureBundle src PaymentBundle • Symfony Extension Point • keine Domain-Trennung benutzt Namespaces Go Mono-Bundle oder Bundleless Bundles

Slide 18

Slide 18 text

@el_stoffel SymfonyLive Berlin 2019 Struktur der Anwendung ApiBundle CoreBundle ExportBundle InfrastructureBundle src PaymentBundle CoreBundle Api Export Infrastructure src Payment ApiBundle CoreBundle ExportBundle InfrastructureBundle PaymentBundle Bundles Mono-Bundle

Slide 19

Slide 19 text

@el_stoffel SymfonyLive Berlin 2019 Struktur der Anwendung ApiBundle CoreBundle ExportBundle InfrastructureBundle src PaymentBundle Api Export Infrastructure src Payment ApiBundle CoreBundle ExportBundle InfrastructureBundle PaymentBundle Kernel.php Bundles Bundleless

Slide 20

Slide 20 text

@el_stoffel SymfonyLive Berlin 2019 Struktur der Anwendung ApiBundle CoreBundle ExportBundle InfrastructureBundle src PaymentBundle Command Export Controller src Api … Bundles Controller & Commands

Slide 21

Slide 21 text

@el_stoffel SymfonyLive Berlin 2019 Struktur der Anwendung namespace App; Namespaces

Slide 22

Slide 22 text

@el_stoffel SymfonyLive Berlin 2019 Struktur der Anwendung Namespaces src Command Controller Entity Form Helper Service Twig Utils Symfony Acme Service CartService.php ImportService.php ProductService.php UserService.php 10K LLOC

Slide 23

Slide 23 text

@el_stoffel SymfonyLive Berlin 2019 Struktur der Anwendung Namespaces src Command Controller Entity Form Helper Service Twig Utils Symfony Acme Service CartService.php ImportService.php ProductService.php UserService.php

Slide 24

Slide 24 text

@el_stoffel SymfonyLive Berlin 2019 Struktur der Anwendung Namespaces src Command Controller Entity Form Helper Service Twig Utils Symfony Acme Service User Product Import Cart

Slide 25

Slide 25 text

@el_stoffel SymfonyLive Berlin 2019 Struktur der Anwendung Namespaces src Command Controller Entity Form Helper Service Twig Utils Symfony Acme Service User Factory.php Registration.php Removal.php Product Import Cart

Slide 26

Slide 26 text

@el_stoffel SymfonyLive Berlin 2019 Struktur der Anwendung Namespaces src Command Controller Domain Entity Form Helper Twig Utils Symfony Acme Domain User Factory.php Registration.php Removal.php Product Import Cart

Slide 27

Slide 27 text

@el_stoffel SymfonyLive Berlin 2019 Struktur der Anwendung • prominente Symfony Namespaces 1st-Level • splittet mächtige Service-Klassen • vermeidet generische strukturelle Namespaces Namespaces bessere Wartbarkeit bessere Orientierung

Slide 28

Slide 28 text

@el_stoffel SymfonyLive Berlin 2019 Software Architektur

Slide 29

Slide 29 text

@el_stoffel SymfonyLive Berlin 2019 Konzept Umsetzung Prozess Team Software Entwicklung Software Architektur Workshops OOP & Clean Code Best Practices Pair Programming Testing Dokumentation Code Review Trainings Wissenstransfer Continuous Deployment Turnover Onboarding

Slide 30

Slide 30 text

@el_stoffel SymfonyLive Berlin 2019 OLTP vs. OLAP Software Architektur

Slide 31

Slide 31 text

@el_stoffel SymfonyLive Berlin 2019 Software Architektur • Online Transactional Processing • abgeschlossene kleine Transaktionen • Transaktion / Request • viele Requests & viele Nutzer OLTP Häufiger Usecase bei Webseiten

Slide 32

Slide 32 text

@el_stoffel SymfonyLive Berlin 2019 Software Architektur • Online Analytical Processing • aufwändigere Queries über viele Datensätze • Reporting • wenige Nutzer OLAP Meistens nachgelagert

Slide 33

Slide 33 text

@el_stoffel SymfonyLive Berlin 2019 OLTP Software Architektur

Slide 34

Slide 34 text

@el_stoffel SymfonyLive Berlin 2019 Transaktionen Software Architektur

Slide 35

Slide 35 text

@el_stoffel SymfonyLive Berlin 2019 Use Cases Software Architektur

Slide 36

Slide 36 text

@el_stoffel SymfonyLive Berlin 2019 HTTP-Request View Controller Model Software Architektur

Slide 37

Slide 37 text

@el_stoffel SymfonyLive Berlin 2019 HTTP-Request View Controller Model Software Architektur

Slide 38

Slide 38 text

@el_stoffel SymfonyLive Berlin 2019 HTTP-Request View Controller Model Software Architektur

Slide 39

Slide 39 text

@el_stoffel SymfonyLive Berlin 2019 HTTP-Request View Controller Domain Use Case Entity Services Services Software Architektur

Slide 40

Slide 40 text

@el_stoffel SymfonyLive Berlin 2019 HTTP-Request View Controller Domain Use Case Entity Services Services Persistence Transaktion Software Architektur

Slide 41

Slide 41 text

@el_stoffel SymfonyLive Berlin 2019 Beispiel Checkout Submit Software Architektur

Slide 42

Slide 42 text

@el_stoffel SymfonyLive Berlin 2019 HTTP-Request View Controller Domain Use Case Entity Services Services Persistence Software Architektur

Slide 43

Slide 43 text

@el_stoffel SymfonyLive Berlin 2019 POST-Request Domain Services Services Persistence Controller Use Case Entity Software Architektur

Slide 44

Slide 44 text

@el_stoffel SymfonyLive Berlin 2019 POST-Request CheckoutController::submit Domain Checkout::submit Services Services Persistence Cart Order Confirmation Software Architektur

Slide 45

Slide 45 text

@el_stoffel SymfonyLive Berlin 2019 POST-Request CheckoutController::submit Domain Checkout::submit Services Services Persistence Cart Order Confirmation Software Architektur

Slide 46

Slide 46 text

@el_stoffel SymfonyLive Berlin 2019 Software Architektur Controller OrderCreatedEvent SubmitCheckoutHandler SubmitCheckoutCommand OrderCreatedListener ClaimStockCommand ClaimStockHandler StockClaimedEvent StockClaimedListener ChargePaymentCommand ChargePaymentHandler …

Slide 47

Slide 47 text

@el_stoffel SymfonyLive Berlin 2019 Flexibilität vs. Stabilität Software Architektur

Slide 48

Slide 48 text

@el_stoffel SymfonyLive Berlin 2019 Flexibilität vs. Wartbarkeit Software Architektur

Slide 49

Slide 49 text

@el_stoffel SymfonyLive Berlin 2019 Software Architektur • 1-zu-1-Kopplung an Controller / Command • zentralisiert Ausführung der Operationen • Integration-Layer • Transaktionssteuerung Use Case

Slide 50

Slide 50 text

@el_stoffel SymfonyLive Berlin 2019 POST-Request CheckoutController::submit Domain Checkout::submit Services Services Persistence Cart Order Confirmation Software Architektur

Slide 51

Slide 51 text

@el_stoffel SymfonyLive Berlin 2019 Rich vs. Anemic Software Architektur

Slide 52

Slide 52 text

@el_stoffel SymfonyLive Berlin 2019 Software Architektur • Fokus auf strukturierten Daten • einfach implementiert oder generiert • keine (kaum) Logik • potentiell invalide Anemic Domain Models

Slide 53

Slide 53 text

@el_stoffel SymfonyLive Berlin 2019 Software Architektur • Fokus auf strukturierten Daten • einfach implementiert oder generiert • keine (kaum) Logik • potentiell invalide Anemic Domain Models

Slide 54

Slide 54 text

@el_stoffel SymfonyLive Berlin 2019 Software Architektur • strukturierten Daten und Logik • immer valider Zustand • definieren State-Transitionen • sehr gut testbar Rich Domain Models

Slide 55

Slide 55 text

@el_stoffel SymfonyLive Berlin 2019 Software Architektur • strukturierten Daten und Logik • immer valider Zustand • definieren State-Transitionen • sehr gut testbar Rich Domain Models

Slide 56

Slide 56 text

@el_stoffel SymfonyLive Berlin 2019 Testing

Slide 57

Slide 57 text

@el_stoffel SymfonyLive Berlin 2019 Konzept Umsetzung Prozess Team Software Entwicklung Software Architektur Workshops OOP & Clean Code Best Practices Pair Programming Testing Dokumentation Code Review Trainings Wissenstransfer Continuous Deployment Turnover Onboarding

Slide 58

Slide 58 text

@el_stoffel SymfonyLive Berlin 2019 Testing Pyramide Testing

Slide 59

Slide 59 text

@el_stoffel SymfonyLive Berlin 2019 Testing Unit Tests Service Tests UI Tests billig & schnell langsam & teuer Isolation Integration

Slide 60

Slide 60 text

@el_stoffel SymfonyLive Berlin 2019 Testing Unit Tests Service Tests UI Tests Domain Services Services Persistence Controller Use Case Entity Logik möglichst tief in Domain + Unit Tests

Slide 61

Slide 61 text

@el_stoffel SymfonyLive Berlin 2019 Testing

Slide 62

Slide 62 text

@el_stoffel SymfonyLive Berlin 2019 Testing BEWARE OF THE MOCK

Slide 63

Slide 63 text

@el_stoffel SymfonyLive Berlin 2019 Prozess

Slide 64

Slide 64 text

@el_stoffel SymfonyLive Berlin 2019 Konzept Umsetzung Prozess Team Software Entwicklung Software Architektur Workshops OOP & Clean Code Best Practices Pair Programming Testing Dokumentation Code Review Trainings Wissenstransfer Continuous Deployment Turnover Onboarding

Slide 65

Slide 65 text

@el_stoffel SymfonyLive Berlin 2019 Prozess Entwicklung • Klar definierter Scope • Abgestimmte Umsetzung • Pair Programming • Boy-Scout-Rule

Slide 66

Slide 66 text

@el_stoffel SymfonyLive Berlin 2019 Prozess Entwicklung Pull Request • Zuerst selbst reviewen • reviewbare PRs – klein oder Commit-Splittung • gebt Kontext

Slide 67

Slide 67 text

@el_stoffel SymfonyLive Berlin 2019 Prozess Entwicklung Pull Request Pipeline • Linting & Validation • Code Style • Statische Analysen • Tests

Slide 68

Slide 68 text

@el_stoffel SymfonyLive Berlin 2019 Prozess Entwicklung Pull Request Pipeline • Linting & Validation • Code Style • Statische Analysen • Tests

Slide 69

Slide 69 text

@el_stoffel SymfonyLive Berlin 2019 Prozess Entwicklung Pull Request Pipeline Review • ihr seid ein Team • Software-Qualität im Fokus • redet drüber • lernt voneinander

Slide 70

Slide 70 text

@el_stoffel SymfonyLive Berlin 2019 Prozess Entwicklung Pull Request Pipeline Review • schneller Durchfluss muss möglich sein • Vorbedingung für Continuous [D|I] • Kopplung von Prozess, Produktivität und Frustration

Slide 71

Slide 71 text

@el_stoffel SymfonyLive Berlin 2019 Recap

Slide 72

Slide 72 text

@el_stoffel SymfonyLive Berlin 2019 Struktur der Anwendung • erkennbare Symfony-Struktur • Kapselung der Domain nach Use Cases • Logik möglichst tief in Domain-Objekten • Unit-Testing der Domain-Objekte • Pipeline und Reviews im Entwicklungsprozess Recap

Slide 73

Slide 73 text

@el_stoffel SymfonyLive Berlin 2019 Ende

Slide 74

Slide 74 text

@el_stoffel SymfonyLive Berlin 2019 Vielen Dank!

Slide 75

Slide 75 text

@el_stoffel SymfonyLive Berlin 2019 joind.in/talk/387e8

Slide 76

Slide 76 text

@el_stoffel SymfonyLive Berlin 2019 joind.in/talk/387e8

Slide 77

Slide 77 text

@el_stoffel SymfonyLive Berlin 2019 Fragen?