Patterns of Organic 
Architecture 
Madman's diary 
By 
Jarosław Pałka
… A word of warning … 
It is not may intention to make you feel offended, 
this talk is 
my view of the world, 
my experience, 
my life, 
my twisted sens of humor 
Respect it!!!
and remember 
you can always leave the room 
you can always talk to me 
and whatever people say 
I am just a human being
About me 
work://chief_architect@lumesse 
owner://symentis.pl 
twitter://j_palka 
blog://geekyprimitives.wordpress.com 
scm:bitbucket://kcrimson 
scm:github://kcrimson
What does society think I do?
What does my wife think I do?
What do I really do?
~ 8 companies in 16 years 
~ 26 projects
and just 
...ONE... 
project built from 
...scratch...
How do I feel about it?
I am feeling 
lucky!
What I will not learn today 
from this talk? 
Which mixture of patterns, 
xDD, 
languages, 
frameworks And paradigms 
will lead me to success
But you will learn how to live 
with... 
Monolithic, legacy code base, 
which gets closer and closer with 
each line to borders of human 
capabilities, 
and is about to colapse 
into a black hole, 
which is going to suck all living 
developers within its reach
We are living in a 
...Big Ball of Mud...
Autogenerated Stovepipe 
Stovepipe Enterprise 
Jumble 
Stovepipe System 
Cover Your Assets 
Vendor Lock-In 
Wolf Ticket 
Architecture by Implication 
Warm Bodies 
Design by Committee 
Swiss Army Knife 
Reinvent the Wheel 
The Grand Old Duke of York
What is common to all these 
cases?
Complexity
Do you need proof?
Let me give you the proof!!!
„I fucking love science”
System's thinking 
System dynamics 
Complexity theory 
Strange Attractor
The Gap
How do organizations 
work around it?
Let's hire more students!!!
Let rewrite it from 
...scratch... 
(of course in newest, coolest technology 
we know shit about)
You may ask, why?
Time is not on our side 
Few „extra features” everybody is 
waiting for? 
Too much faith in technology? 
Too often these projects are seen as 
purely technical? 
Ignorance? 
Arogance?
If it all doesn't work, 
why not to try something 
different?
The Gap
Patterns of organic 
architecture
Architecture is a process 
which goal is to 
transform your system 
from one design to 
another design
Architecture is a process 
which goal is to 
transform your system 
from one design to 
another design
Architecture is a process 
which goal is to 
transform your system 
from one design to 
another design
Understand the Gap 
↓ 
Understand Context 
↓ 
Identify Constraints
You can't control what you 
can't measure 
Tom DeMarco, 
Controlling Software Projects,
You can't reason about what 
you can't measure 
@j_palka 
from a book which will never be written
You can't reason about what 
you can't measure 
@j_palka 
from a book which will never be written
So, how to measure your 
architecture?
Complexity Resilience
Source code 
the truth will 
tell you
Listen to 
the system 
you must
SCM 
Bug tracker 
Continous integration 
Static code analisys
Let's find stable parts of the 
system
# count complexity per each file 
find . -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 changes 
echo '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
Michael Feathers Quadrant
uglystables designflaw 
tools 
breedinggrounds
Let's find fragile parts of the 
system
#fetch all jobs 
jobs_rsp = requests.get( 
"https://primitive.ci.cloudbees.com/job/roadrunner/api/python") 
#all builds urls 
build_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
(('.../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)
Package principles 
aka 
Are my classes in a right 
place?
(echo "<changes>" && hg log --template 
"<changeset> 
{files % '<file>{file}</file>n'} 
</changeset>n" 
&& echo "</changes>") > out.xml
+ 
Neo4j 
(jqassistant)
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"] | 
+-----------------------------------------------------------------------------------------------------------+
Can you please show me these 
patterns of 
organic architecture?
Sow and Gro w
„aka” refactoring 
compulsive „refactoring” is evil 
no user stories „refactor X” 
before you start, think, is it worth it? 
don't ask for permissions, it is better to ask for 
forgivness 
give „technical debt” meaning
„visual management” 
Define limited number of metrics 
Use only these metrics which 
support your goals 
because 
„You get what you measure”
SSooww aanndd hhaarrvveesstt
„aka” modularization 
Modularize to stable parts of the system 
otherwise you will make your 
system even more unstable 
but before you start ...
let's build some 
...„framework” ...
Architecture is a process 
which goal is to 
transform your system 
from one design to 
another design
… clearly define goals … 
… strategy adjusted to needs and 
capabilties … 
… give yourself some design space … 
Don't get paralized by „big design (tm)” 
You don't need to know answers to all 
questions 
… because your goal is a moving target ...
What if your architecture 
would look like this?
Batch processing separated from online 
Modules communicate asynchronously 
Users see system as one 
And communicate with system 
synchronously 
The only thing we share is a model of 
our system 
mvn clean install < 60 sec
Every module has to 
inherit these principles 
And can introduce new one 
which makes these system 
wide principles more specific
Composting
But sometimes, 
despite our 
hard work, 
knowledge and 
experience
Complexity
Do you know how your users use 
your application? 
Do you know that your biggest 
customer is no longer using your 
system? 
Do you know that some „killer 
feature” is not sooo „killer”?
How can I know it all?
/var/log/httpd/access.log 
Instrument your code? 
Aspects? 
Byteman? 
Bug tracker? 
People from support?
Don't buy expensive tools 
Invest in your creativity 
You know your system better, 
then some third party provider
But please don't comment 
out code 
Use your SCM 
… throw this shit out...
What's next?
Hierarchy 
↓ 
Self-Organization 
↓ 
Resilience
System's resilience is often 
sacrificed for purposes of 
short-term productivity 
and stability.
Productivity and stability 
are the 
usual excuses for turning 
creative human beings into 
mechanical adjuncts 
to production processes.
Or for establishing 
bureaucracies and theories 
of knowledge that 
treat people as if they were 
only numbers. 
Donella Meadows, thinking in systems a primer
Thank you!!!

Patterns for organic architecture codedive

  • 1.
    Patterns of Organic Architecture Madman's diary By Jarosław Pałka
  • 2.
    … A wordof warning … It is not may intention to make you feel offended, this talk is my view of the world, my experience, my life, my twisted sens of humor Respect it!!!
  • 3.
    and remember youcan always leave the room you can always talk to me and whatever people say I am just a human being
  • 4.
    About me work://chief_architect@lumesse owner://symentis.pl twitter://j_palka blog://geekyprimitives.wordpress.com scm:bitbucket://kcrimson scm:github://kcrimson
  • 5.
    What does societythink I do?
  • 7.
    What does mywife think I do?
  • 9.
    What do Ireally do?
  • 11.
    ~ 8 companiesin 16 years ~ 26 projects
  • 12.
    and just ...ONE... project built from ...scratch...
  • 13.
    How do Ifeel about it?
  • 14.
    I am feeling lucky!
  • 15.
    What I willnot learn today from this talk? Which mixture of patterns, xDD, languages, frameworks And paradigms will lead me to success
  • 16.
    But you willlearn how to live with... Monolithic, legacy code base, which gets closer and closer with each line to borders of human capabilities, and is about to colapse into a black hole, which is going to suck all living developers within its reach
  • 18.
    We are livingin a ...Big Ball of Mud...
  • 19.
    Autogenerated Stovepipe StovepipeEnterprise Jumble Stovepipe System Cover Your Assets Vendor Lock-In Wolf Ticket Architecture by Implication Warm Bodies Design by Committee Swiss Army Knife Reinvent the Wheel The Grand Old Duke of York
  • 20.
    What is commonto all these cases?
  • 21.
  • 22.
  • 23.
    Let me giveyou the proof!!!
  • 24.
  • 25.
    System's thinking Systemdynamics Complexity theory Strange Attractor
  • 29.
  • 30.
    How do organizations work around it?
  • 31.
    Let's hire morestudents!!!
  • 32.
    Let rewrite itfrom ...scratch... (of course in newest, coolest technology we know shit about)
  • 34.
  • 35.
    Time is noton our side Few „extra features” everybody is waiting for? Too much faith in technology? Too often these projects are seen as purely technical? Ignorance? Arogance?
  • 36.
    If it alldoesn't work, why not to try something different?
  • 37.
  • 38.
    Patterns of organic architecture
  • 40.
    Architecture is aprocess which goal is to transform your system from one design to another design
  • 41.
    Architecture is aprocess which goal is to transform your system from one design to another design
  • 42.
    Architecture is aprocess which goal is to transform your system from one design to another design
  • 43.
    Understand the Gap ↓ Understand Context ↓ Identify Constraints
  • 44.
    You can't controlwhat you can't measure Tom DeMarco, Controlling Software Projects,
  • 45.
    You can't reasonabout what you can't measure @j_palka from a book which will never be written
  • 46.
    You can't reasonabout what you can't measure @j_palka from a book which will never be written
  • 47.
    So, how tomeasure your architecture?
  • 48.
  • 49.
    Source code thetruth will tell you
  • 50.
    Listen to thesystem you must
  • 51.
    SCM Bug tracker Continous integration Static code analisys
  • 52.
    Let's find stableparts of the system
  • 53.
    # count complexityper each file find . -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 changes echo '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
  • 55.
  • 56.
  • 57.
    Let's find fragileparts of the system
  • 58.
    #fetch all jobs jobs_rsp = requests.get( "https://primitive.ci.cloudbees.com/job/roadrunner/api/python") #all builds urls build_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
  • 59.
    (('.../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)
  • 60.
    Package principles aka Are my classes in a right place?
  • 61.
    (echo "<changes>" &&hg log --template "<changeset> {files % '<file>{file}</file>n'} </changeset>n" && echo "</changes>") > out.xml
  • 62.
  • 63.
    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"] | +-----------------------------------------------------------------------------------------------------------+
  • 64.
    Can you pleaseshow me these patterns of organic architecture?
  • 65.
  • 66.
    „aka” refactoring compulsive„refactoring” is evil no user stories „refactor X” before you start, think, is it worth it? don't ask for permissions, it is better to ask for forgivness give „technical debt” meaning
  • 67.
    „visual management” Definelimited number of metrics Use only these metrics which support your goals because „You get what you measure”
  • 68.
  • 69.
    „aka” modularization Modularizeto stable parts of the system otherwise you will make your system even more unstable but before you start ...
  • 70.
    let's build some ...„framework” ...
  • 72.
    Architecture is aprocess which goal is to transform your system from one design to another design
  • 73.
    … clearly definegoals … … strategy adjusted to needs and capabilties … … give yourself some design space … Don't get paralized by „big design (tm)” You don't need to know answers to all questions … because your goal is a moving target ...
  • 75.
    What if yourarchitecture would look like this?
  • 76.
    Batch processing separatedfrom online Modules communicate asynchronously Users see system as one And communicate with system synchronously The only thing we share is a model of our system mvn clean install < 60 sec
  • 77.
    Every module hasto inherit these principles And can introduce new one which makes these system wide principles more specific
  • 78.
  • 79.
    But sometimes, despiteour hard work, knowledge and experience
  • 80.
  • 81.
    Do you knowhow your users use your application? Do you know that your biggest customer is no longer using your system? Do you know that some „killer feature” is not sooo „killer”?
  • 82.
    How can Iknow it all?
  • 83.
    /var/log/httpd/access.log Instrument yourcode? Aspects? Byteman? Bug tracker? People from support?
  • 84.
    Don't buy expensivetools Invest in your creativity You know your system better, then some third party provider
  • 85.
    But please don'tcomment out code Use your SCM … throw this shit out...
  • 86.
  • 87.
  • 88.
    System's resilience isoften sacrificed for purposes of short-term productivity and stability.
  • 89.
    Productivity and stability are the usual excuses for turning creative human beings into mechanical adjuncts to production processes.
  • 90.
    Or for establishing bureaucracies and theories of knowledge that treat people as if they were only numbers. Donella Meadows, thinking in systems a primer
  • 91.