Patterns for organic architecture

88
Wzorce organicznej architektury Pamiętnik szaleńca

Transcript of Patterns for organic architecture

Page 1: Patterns for organic architecture

Wzorce organicznej architektury

Pamiętnik szaleńca

Page 2: Patterns for organic architecture

Kim jestem

work://chief_architect@lumesse

owner://symentis.pl

twitter://j_palka

blog://geekyprimitives.wordpress.com

scm:bitbucket://kcrimson

scm:github://kcrimson

Page 3: Patterns for organic architecture

Co społeczeństwo myśli o mnie?

Page 4: Patterns for organic architecture
Page 5: Patterns for organic architecture

Co moja żona myśli o mojej pracy?

Page 6: Patterns for organic architecture
Page 7: Patterns for organic architecture

Co ja tak naprawdę robię?

Page 8: Patterns for organic architecture
Page 9: Patterns for organic architecture

~ 8 firm w przeciągu 16 lat

~ 26 projektów

Page 10: Patterns for organic architecture

… i tylko jeden projekt budowany od podstaw ...

Page 11: Patterns for organic architecture

Jak się z tym czuje?

Page 12: Patterns for organic architecture

I am feeling I am feeling lucky!lucky!

Page 13: Patterns for organic architecture

Czego się dziś nie dowiem?

Która kombinacja wzorców, xDD, języków, frameworków i paradygmatów gwarantuje

sukces

Page 14: Patterns for organic architecture

Dowiem się za to jak nie oszaleć...

Pracując z monolityczną, odziedziczoną, masą kodu, który zbliża się do granic wytrzymałości,

by za chwilę zapaść się pod własnym ciężarem, tworząc czarną dziurę, która pochłonie

wszystkich żywych programistów w okolicy

Page 15: Patterns for organic architecture
Page 16: Patterns for organic architecture

We are living in a ...

Big Ball of Mud

Page 17: Patterns for organic architecture

Autogenerated StovepipeStovepipe Enterprise

JumbleStovepipe System

Cover Your AssetsVendor Lock-In

Wolf TicketArchitecture by Implication

Warm BodiesDesign by Committee

Swiss Army KnifeReinvent the Wheel

The Grand Old Duke of York

Page 18: Patterns for organic architecture

Co łączy te wszystkie przypadki?

Page 19: Patterns for organic architecture

Złożoność

Page 20: Patterns for organic architecture

Dowód?

Page 21: Patterns for organic architecture

„I fucking love science”

Page 22: Patterns for organic architecture

Myślenie systemowe

System dynamics

Teorie złożoności

Strange Attractor

Page 23: Patterns for organic architecture
Page 24: Patterns for organic architecture
Page 25: Patterns for organic architecture
Page 26: Patterns for organic architecture

The Gap

Page 27: Patterns for organic architecture

Jak organizacje sobie z tym radzą?

Page 28: Patterns for organic architecture

Może by tak zatrudnić więcej studentów?

Page 29: Patterns for organic architecture

Przepiszmy to wszystko...

(najlepiej w technologi i na platformę o której nie mamy zielonego pojęcia)

Page 30: Patterns for organic architecture
Page 31: Patterns for organic architecture

Dlaczego?

Page 32: Patterns for organic architecture

Czas?

Kilka „extra feature” na które wszyscy czekali?

Nadmierna wiara w siłę sprawczą technologii?

Projekty często postrzegane jak czysto techniczne?

Ignorancja?

Arogancja?

Page 33: Patterns for organic architecture

A może by tak?

Page 34: Patterns for organic architecture

The Gap

Page 35: Patterns for organic architecture

Wzorce organicznej architektury

Page 36: Patterns for organic architecture
Page 37: Patterns for organic architecture

Architektura to proces który ma na celu

transformację twojego systemu

Page 38: Patterns for organic architecture

Architektura to proces który ma na celu

transformację twojego systemu

Page 39: Patterns for organic architecture

Architektura to proces który ma na celu

transformację twojego systemu

Page 40: Patterns for organic architecture

Gap

Context

Constraints

Page 41: Patterns for organic architecture

You can't control what you can't measureTom DeMarco,

Controlling Software Projects,

Page 42: Patterns for organic architecture

You can't Reason about what you can't measure

Page 43: Patterns for organic architecture

Miara jakości architektury?

Page 44: Patterns for organic architecture

Complexity Resilience

Page 45: Patterns for organic architecture

Source code the truth will

tell you

Page 46: Patterns for organic architecture

Listen to the system

you must

Page 47: Patterns for organic architecture

SCM

Bug tracker

Continous integration

Static code analisys

Page 48: Patterns for organic architecture

Znajdźmy stabilne obszary systemu

Page 49: Patterns for organic architecture

# count complexity per each filefind . -iname jacoco.csv | xargs tail -q -n +2 | awk -F , '{gsub("\.","/",$2);print ($1"/src/main/java/"$2"/"$3".java"),$10+$11}' | sort > coverage.txt

# count number of changesecho 'changeset="{files}"' > files.style; echo 'file="\n{file}"' >> files.style

hg log --style files.style | sort | uniq -c | awk '{print $2,$1}' > changes.txt

# merge changes join coverage.txt changes.txt

Page 50: Patterns for organic architecture
Page 51: Patterns for organic architecture

Michael Feathers Quadrant

Page 52: Patterns for organic architecture

public enum Quadrant {

/* * * low complexity, little changes - simple utilities. * / tools,

/* * * simple yet frequently touched area of your code. Core of it, yet done well * and expanding. New features grow, new classes are extracted, complexity * is kept at bay. Keep it that way! * / breedinggrounds,

/* * * Ugly files but stable - written once for specific purpose, which they * fulfill well enough. High complexity makes them risky to touch, but is * there any need to? * * Ugly Stables also because of Hercules and Augias's stables... ;-) * / uglystables,

/* * * Code fitting here is fraught with complexity and changed often. Meaning, * you either didn't got the client's needs r ight and need to make lotsa * changes now, or you mis-designed and now have to work around it. * Or there's simply a number of bugs... * / designflaw

}

Page 53: Patterns for organic architecture

tools

uglystables designflaw

breedinggrounds

Page 54: Patterns for organic architecture

Znajdźmy kruche obszary systemu

Page 55: Patterns for organic architecture

#fetch all jobsjobs_rsp = requests.get("https://primitive.ci.cloudbees.com/job/roadrunner/api/python")#all builds urlsbuild_urls = [x['url'] for x in eval(jobs_rsp.content)['builds']]

pairs = []for build_url in build_urls: build = eval(requests.get("%sapi/python" % (build_url)).content) result = build['result']

changeSetItems = build['changeSet']['items'] if changeSetItems and not result == 'SUCCESS': affectedPaths = build['changeSet']['items'][0]['affectedPaths']

for i in itertools.permutations(affectedPaths,2): pairs.append(i)

counter = collections.Counter(pairs).most_common(5)for pair in counter: print pair

Page 56: Patterns for organic architecture

(('.../cli/CliConfigurationBuilderTest.java', '.../cli/RunTest.java'), 3)(('.../cli/RunTest.java', '.../cli/CliConfigurationBuilderTest.java'), 3)(('.../cli/CliConfigurationBuilderTest.java', '.../cli/BenchTest.java'), 3)(('.../cli/BenchTest.java', '.../cli/RunTest.java'), 3)(('.../cli/RunTest.java', '.../cli/BenchTest.java'), 3)

Page 57: Patterns for organic architecture

Czy ja to wszystko dobrze spakowałem?

Package principles

aka

Coś tu za chwilę wyleci w powietrze

Page 58: Patterns for organic architecture

(echo "<changes>" && hg log --template "<changeset>

{files % '<file>{file}</file>\n'}</changeset>\n"

&& echo "</changes>") > out.xml

Page 59: Patterns for organic architecture

+Neo4j

Page 60: Patterns for organic architecture

neo4j-sh (?)$ MATCH (a)-[c:`changeset`]->(b) RETURN labels(a),c.times,labels(b) order by c.times desc limit 5; +-----------------------------------------------------------------------------------------------------------+ | labels(a) | c.times | labels(b) | +-----------------------------------------------------------------------------------------------------------+ | [".../listeners/SummaryScenarioListener.java"] | 13 | [".../listeners/LoggingScenarioListener.java"] | | [".../listeners/LoggingScenarioListener.java"] | 13 | [".../listeners/SummaryScenarioListener.java"] | | ["pom.xml"] | 12 | ["roadrunner-core/pom.xml] | | [".../cli/BenchTest.java"] | 12 | [".../cli/RunTest.java"] | | [".../cli/RunTest.java"] | 12 | [".../cli/BenchTest.java"] | +-----------------------------------------------------------------------------------------------------------+

Page 61: Patterns for organic architecture

To gdzie te wzorce organicznej architektury?

Page 62: Patterns for organic architecture

Zasiej i pielęnguj

Page 63: Patterns for organic architecture

„aka” refactoring

kompulsywny „refactoring” to zło

unikaj „historyjek” typu „zrefaktoryzować X”

zanim zaczniesz, zastanów się czy warto

nie pytaj o pozwolenie, raczej proś o przebaczenie

nadaj „technical debt” znaczenie

Page 64: Patterns for organic architecture

„visual management”

wyznacz tylko kilka miar jakości

Tylko te które wspierają twoje cele

ponieważ

„You get what you measure”

Page 65: Patterns for organic architecture

Zasiej i zbierzZasiej i zbierz

Page 66: Patterns for organic architecture

„aka” modularyzacja

modularyzuj do stabilnych elementów systemów

zanim jednak zaczniesz ...

Page 67: Patterns for organic architecture

… zbuduj „framework” ...

Page 68: Patterns for organic architecture
Page 69: Patterns for organic architecture

Architektura to proces który ma na celu

transformację twojego systemu

Page 70: Patterns for organic architecture

… musisz mieć jasno określony cel …

… strategia dobrana do potrzeb i możliwości …

… daj sobie przestrzeń na zmianę zdania …

nie daj się znowu sparaliżować „big design (tm)”

… gdyż twój cel może się zmienić ...

Page 71: Patterns for organic architecture
Page 72: Patterns for organic architecture

co jeśli twój „big design (TM)”

wyglądałby tak...

Page 73: Patterns for organic architecture

procesy wsadowe (batch) odseparowane

moduły komunikują się ze sobą asynchronicznie

Użytkownicy widzą system jako jedność

i komunikują się synchronicznie

Jedyne co współdzielimy w systemie to mentalny model

mvn clean install < 60 sekund

Page 74: Patterns for organic architecture

Każdy moduł musi dziedziczyć kontekst i ograniczenia

Może też wprowadzać specyficzne, lokalne ograniczenia w kontekście poszczególnych

modułów

Page 75: Patterns for organic architecture

Kompostowanie

Page 76: Patterns for organic architecture

Czasami mimo wysiłków, pracy...

i szczerych chęci

Którymi piekło jest wybrukowane

Page 77: Patterns for organic architecture

Complex

ity

Page 78: Patterns for organic architecture

Czy wiesz jak twoi użytkownicy korzystają z systemu?

Czy wiesz że twój „kluczowy” klient nie korzysta już z systemu od 5 lat?

Czy wiesz że „killer feature” nie zachwycił rynku a ty ciągle utrzymujesz ten kod?

Page 79: Patterns for organic architecture

Skąd ja mam to wiedzieć?

Page 80: Patterns for organic architecture

/var/log/httpd/access.log

Zinstrumentuj kod?

Aspekty?

Byteman?

Bug tracker?

Ludzie z utrzymania?

Page 81: Patterns for organic architecture

Nie inwestuj w drogie narzędzia

Będziesz czekał miesiącami na „approval”

A potem narzędzie i tak zawiedzie twoje oczekiwania :)

Zainwestuj w kreatywność

Page 82: Patterns for organic architecture

Tylko proszę bez „wykomentowania” kodu

Twój SCM będzie pamiętał

… po prostu wyrzuć to...

Page 83: Patterns for organic architecture

Czas podsumowań

Page 84: Patterns for organic architecture

Hierarchy

Self-Organization

Resilience

Page 85: Patterns for organic architecture

System's resilience is often sacrificed for purposes of

short-term productivity and stability.

Page 86: Patterns for organic architecture

Productivity and stability are theusual excuses for turning creative human beings

into mechanical adjunctsto production processes.

Page 87: Patterns for organic architecture

Or for establishing bureaucracies and theories of knowledge that

treat people as if they were only numbers.

Donella Meadows, thinking in systems a primer

Page 88: Patterns for organic architecture

Dziękuję!!!