design patterns workshop - yow! conferences · shearing layers –stuart brand, how buildings learn...
Post on 06-Jul-2020
0 Views
Preview:
TRANSCRIPT
12/10/2015
1
Sustainable Architecture“Supporting Data Variability”
YOW!―Dec 3rd–11th, 2015Joseph W. Yoder―@metayoda
Copyright 2015 Joseph W. Yoder & The Refactory, Inc.
Sustaining Your Architecture
Motivation:Need to Quickly Adapt to Change Business Rules and Domain Elements
are varying a lot and changing quickly:
New calculations for insurance policies
and new types of policies offered
Online store catalog with new products
and services and rules applying to them
New cell phone product and services…
Need quick ways to
to these varying requirements
D103626
140505A1
12/10/2015
2
Sustaining Your Architecture
Core Ideas
Separate what changes
from what doesn’t change
Protect core components
Find the variability points and provide
ways to support this variability in data
Description of changes (metadata)
Hook Points for variability
Dynamic Process Rules using Metadata
3
Sustaining Your Architecture
Patterns or Techniques
That Add Value
4
12/10/2015
3
Sustaining Your Architecture
Data Import Orders
Provided a standard
format for data imports
Lots of duplication
If Clients
vary
we had
self-
Imports that need
had client specific rules, required
a complete, self
Sustaining Your Architecture
Data Import Orders
Provided a standard
format for data imports
Lots of duplication
If Clients
vary
we had
self-
Imports that need
had client specific rules, required
a complete, self
Many Clients (growing)
Varying Data Formats
XML
Excel
Delimited with Header
ASCII Fixed Format
Tagged Line
12/10/2015
4
Sustaining Your Architecture
Sweep It Under the Rug
Cover it up to keep other areas clean
(Façade and other Wrapper Patterns)
Sustaining Your Architecture
Evolving “Import Orders”
12/10/2015
5
Sustaining Your Architecture
Shearing Layers
–Stuart Brand, How Buildings Learn
Sustaining Your Architecture
Yoder and Foote’s
Software Shearing Layers“Factor your system so that artifacts that
change at similar rates are together”
– Foote & Yoder, Ball of Mud, PLoPD4
• The platform
• Infrastructure
• Data schema
• Standard frameworks, components, services
• Abstract classes, Interfaces, APIs, Schemas
• Classes, Prototypes
• Code (functions/lambdas, algorithms)
• Data (metadata)
LayersSlower
Faster
12/10/2015
6
Sustaining Your Architecture
Put a rug at the Front DoorProtect Important Components!
Keep other parts of the system clean
Sometimes Glue code (Mediators) helps
keep others parts of the system cleaner
(Anti-Corruption Layer – Eric Evans)
Sustaining Your Architecture
Wipe your Feet
at the Front DoorALIAS: ENCAPSULATE AND IGNORE
KEEPING THE INTERNALS CLEAN
Patterns for
Sustaining Architecture
PLoP 2012 Paper
Protected Components
S1
S2
S3
Sn
Adapter/Proxy/Façade
FrontdoorWrapper
Filtering,Cleansing,Security Checks
...
12/10/2015
7
Sustaining Your Architecture
Data Import Processing
Shearing Layers and Wipe
your Feet at the Front Door
Filtering and Cleansing Sequence to keep
Place Order Interface Clean
Sustaining Your Architecture
SYSTEMS NEED TO QUICKLY
ADAPT TO VARIATIONS!!!
12/10/2015
8
Sustaining Your Architecture
In my youth…two bad words
M and R words“Metadata and Reflection”
Sustaining Your Architecture
The Power of Metadata
Code is data, data is code. Everything is data. And data can drive behavior
Meta data simply describes other data.
“If something is going to vary in a predictable way, store the description of the variation in a database so that it
is easy to change” – Ralph Johnson
"Anything you can do, I can do Meta"
"Meta is Beta"
12/10/2015
9
Sustaining Your Architecture
Metadata
Sustaining Your Architecture
What is Metadata“Data about Data”
Document Type Book
AuthorsErich Gamma, John Vlissides,
Ralph Johnson, and Richard Helm
Year of
Publication1994
TitleDesign Patterns: Elements of
Reusable Object-Oriented Software
Page Count 395
Publisher Addison-Wesley
Description
Software engineering book describing
recurring solutions to common problems
in software design...
12/10/2015
10
Sustaining Your Architecture
public class Car {
// Injectable constructor
@Inject public Car(Engine engine) { ... }
// Injectable field
@Inject private Provider<Seat> seatProvider;
// Injectable package-private method
@Inject void install(Windshield windshield, Trunk trunk) { ... }
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD) //can use in method only.
public @interface Test {…}
Metadata―Annotations
Sustaining Your Architecture
Metadata―A little goes far
Online Store Catalog
Sweaters (size=(S,M,L,XL,…),
color=(red, green, blue, yellow,…))
Canoes (length=float, width=float, floatFactor=boolean,
color=(red, brown, blue, silver,…))
….
12/10/2015
11
Sustaining Your Architecture
Metadata―Order Import FirstName,LastName,ShipAddress,DivisionName
Foo,Bar,"7 Florida Drive Urbana IL",
XML output will be:
<File>
<Record>
Urbana IL</
ionName
</Record>
</File>
<FooBarIncImport>
<FirstName>
<start>1</start>
<end>10</end>
</FirstName>
<LastName>
<start>11</start>
<end>25</end>
</LastName>
…
</FooBarIncImport>
Sustaining Your Architecture
HOW TO DEAL WITH
CHANGING RULES???
Standard Validation Rules:
Address Too Long (> 40 characters)
Duplicate Client Order ID
Duplicate Order Line Number
Insufficient Quantity
Invalid Package Code
Invalid Order Quantity (< 1)
Invalid Request ID
Invalid Stock Number
…
12/10/2015
12
Sustaining Your Architecture
Dynamic Hook PointsEli Acherkan, Atzmon Hen-Tov, David H. Lorenz,
Lior Schachter, Rebecca Wirfs-Brock, Joseph W. Yoder
Asian PLoP 2012
Sustaining Your Architecture
Import Validation
[ValidationRule(“FooBarInc Validation Rule")]
public class FooBarIncValidationRule : ValidationRule {
public FooBarIncValidationRule () : base() { }
public override void Validate(ImportContext context)
…}
Validate
ProcessCore Rules
Load and Process Cleint Specific Rules
Dynamic
Hook Point
Metadata
12/10/2015
13
Sustaining Your Architecture
Metadata―Markup<xsl:stylesheet xmlns:xsl="http://www.w3.org/
1999/XSL/Transform" version="1.0">
<xsl:key match="/publisher/books/book" use="author-ref/@ref"
name="books-by-author"/>
<xsl:template match="/"><bestsellers-list> <xsl:apply-templates
select="/publisher/authors/author"> <xsl:sort select="sum(key('books-by-
author', @id)/sold)"/> <xsl:sort select="last_name"/> </xsl:apply-
templates> </bestsellers-list></xsl:template>
<xsl:template match="author"> <copy> <name> <xsl:value-of
select="last_name"/>, <xsl:value-of select="first_name"/> </name>
<total_publications> <xsl:value-of select="count(key('books-by-author',
@id))"/> </total_publications> <total_sold> <xsl:value-of
select="sum(key('books-by-author', @id)/sold)"/>
</total_sold> <rank> <xsl:value-of select="position()"/>
</rank> </copy> </xsl:template>
</xsl:stylesheet>
Brian Foote: Metadata, The Good, The Bad, The Ugly
Mini-SugarLoaf PLoP, São Paulo, Brazil ― Sept 2011
Sustaining Your Architecture
Paving over the
Wagon Trail
Patterns for Sustaining Architecture
PLoP 2012 Paper
ALIAS: MAKE REPETITIVE TASKS EASIER
STREAMLINING REPETITIVE CODE TASKS
12/10/2015
14
Sustaining Your Architecture
Import Validation
Extended Metadata for Rule
Language—Beginning of DSL
Sustaining Your Architecture
What have we seen?
Shearing Layers
Wipe your Feet
Metadata
Dynamic Hook Points
Paving the Wagon Trail
28
12/10/2015
15
Sustaining Your Architecture
Duck Programming
Reginald Braithwaite Blog:
Duck Programming is any configuration that defines or
controls mission-critical behavior of a software system
that is thought to be “not programming” because it
doesn’t appear to involve programmers, programming
languages, or programming tools
When I see a bird that walks like a duck and swims like
a duck and quacks like a duck, I call that bird a duck…
https://unspace.ca/dev/2012/duck-programming
Sustaining Your Architecture
Downside of
Meta-Architectures
Requires Skilled People
Performance / Security
Lack of Support/Tools
Misused/Abused
Complexity / Over Design
…
12/10/2015
16
Sustaining Your Architecture
Successfully Used For:(some can be found in papers)www.adaptiveobjectmodel.com
Manufacturing Systems
Representing Insurance Policies
Marketing and Campaign Management
Historical Catalogue System
Telephone Billing Systems
Workflow Systems
Medical Observations
Banking and Trading
Validate Equipment Configuration
Documents Management System
Gauge Calibration Systems
Simulation Software …
Sustaining Your Architecture
Being Pragmatic
No Planning
No Design
or Architecture
Sometimes
called Agile
Lot’s of
Upfront
Planning
Lot of Design
& Architecture
Traditional
or Waterfall
Rough
Adaptive
Plan (changing)
Right Balance
of Design
& Architecture
Being Agile
12/10/2015
17
Sustaining Your Architecture
Design Values
Supporting Variability
Respect your system’s shearing layersUnderstand the rates of what changes
Determine & support who should be able
to make changes, when, and at what cost
Make what is too difficult, time
patterns, use data to drive behavior…
Don’t overdesign!!! (Only design
what you need when you need it)
Sustaining Your Architecture
Don’t Overdesign!!!
KISS
12/10/2015
18
Thanks!!!
joe@refactory.com
Twitter: @metayoda
Sustaining Your Architecture
Resources
Adaptive Object Models
www.adaptiveobjectmodel.com
www.metaplop.org
Refactoring www.refactory.com
TeamsThatInnovate
www.teamsthatinnovate.com
Hillside Patterns www.hillside.net
top related