SlideShare a Scribd company logo
1 of 62
Download to read offline
Whoops! Where did my architecture go?
Approaches to architecture management for Java and Spring applications



Oliver Gierke




© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Oliver Gierke

                                                                                        Spring Data
                                                                                        Core/JPA/MongoDB

                                                                                        ogierke@vmware.com
                                                                                        www.olivergierke.de
                                                                                        olivergierke


© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Background
                                 Few years of consulting
                                  Lots of code reviews
                                Eoin Woods‘ talk on InfoQ



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Roadmap
                                         Architecture 101
                                     A Java packages model
                                              Hera



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Architecture 101


© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Know your
                      dependencies

© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Granularity
                                                          Modules
                                                           Layers
                                                        Vertical slices
                                                         Subsystems


© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Granularity
                                                        Java ARchive
                                                          Package
                                                            Class



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Of layers
                                  and slices…

© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Slice A                  Slice B         Slice C


                   Layer 1



                  Layer 2



                  Layer 3



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Layers
                                    Well understood
                                 Known to developers
                               Less important to business



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Slices
                                             Hardly understood
                                             New to developers
                                            Key for business req



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Slice A                  Slice B         Slice C


                   Layer 1



                  Layer 2



                  Layer 3



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
"                      How to implement
                                  an architecture
                                  inside a codebase?


© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Architecture
                                VS.
                             Codebase

© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
"                      How to implement
                                  an architecture
                                  inside a codebase?


© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
"                      How to enforce
                                  an architecture
                                  inside a codebase?


© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Code analysis
                                                                 JDepend
                                                                  Sonar




© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Demo


© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Sonargraph
                               Formerly known as SonarJ




© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Demo


© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
A plain Java
            based approach

© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Slice A                  Slice B         Slice C


                   Layer 1



                  Layer 2



                  Layer 3



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
….${layer}.${slice}
             VS.
     ….${slice}.${layer}

© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Layers first
                          Leaks slice internals
                     Lower layers visible to everyone




© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
"                      Start with less
                                  packages and the
                                  least visibility
                                  possible…

© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Slice A                  Slice B         Slice C


                   Layer 1



                  Layer 2



                  Layer 3



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Slice A                  Slice B         Slice C


                   Layer 1



                  Layer 2



                  Layer 3



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Slices first
                 Start with package per slice
             Expose interfaces and domain types
                Keep implementations private



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Slices first
                        Encapsulates business module
                         Internals understood anyway




© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Subsystems


© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Background
          Risk mgmt. at German public bank
         Quite a few other SpringSource clients




© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
"                      The smallest
                                  plugin system
                                  ever!


© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Host

                          SPI                                              SPI              SPI



                                  Plugin                                                Plugin


© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Context
                                      No OSGi
                                    Spring based
                              Build-time composition
                            Don‘t touch the host system


© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
App

                                     Plugin                                             Plugin


                                                                       Host


© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
"                      How to make the
                                  host aware of the
                                  plugins?


© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
"                      How to dynami-
                                  cally collect Spring
                                  beans of a given
                                  type?

© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
classpath*:META-INF/
       spring/plugin-context.xml




© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
classpath*:META-INF/
                                       spring/plugin-context.xml

                          SPI                                              SPI                      SPI


                           META-INF/spring/                                             META-INF/spring/
                           plugin-context.xml                                           plugin-context.xml




© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
@Component
 public class MyComponentImpl implements TransferService {

      private List<MyPlugin> plugins;

      @Autowired
      public MyComponentImpl(List<MyPlugin> plugins) {
        this.plugins = plugins;
      }
      …
 }

 public interface MyPlugin {
   void doSomething();
 }



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Demo


© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
XML?
                                                   Back in the days




© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
(XML?)
                           Back in the days
                    Probably not a big deal anymore




© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Easy access?


© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
@Component
 public class MyComponentImpl implements TransferService {

      private List<MyPlugin> plugins;

      @Autowired
      public MyComponentImpl(List<MyPlugin> plugins) {
        this.plugins = plugins;
      }
      …
 }

 public interface MyPlugin {
   void doSomething();
 }



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
@Component
 public class MyComponentImpl implements TransferService {

      // Constructor omitted

      public Result myMethod(SomeParameter parameter) {

           // Select the first one to match to invoke?
           // Select multiple ones to invoke?
           // Select and fallback to one if none found?
           // Select and throw an exception if none found?
      }
 }




© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Plugins
                              Selection criterion
                               Callback method
                        Let the implementation decide



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Registry
                                   Equipped with plugins
                                  Common access patterns




© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
public interface Plugin<T> {

      public boolean supports(T delimiter );
 }


 public interface PluginRegistry<S extends Plugin<T>, T> {

      T getPluginFor(S delimiter);
      T getPluginFor(S delimiter, T default);
      <E extends Exception> T getPluginFor(S del, E exception) throws E;

      List<T> getPluginsFor(S delimiter);
      …
 }



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
@Component
 public class MyComponentImpl implements TransferService {

      private PluginRegistry<MyPlugin, String> plugins;

      @Autowired
      public MyComponentImpl(PluginRegistry<MyPlugin, String> plugins) {
        this.plugins = plugins;
      }
      …
 }

 public interface MyPlugin extends Plugin<String> {
   void doSomething();
 }



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
@Component
 public class MyComponentImpl implements TransferService {
   private final MyPlugin defaultPlugin = new MyDefaultPlugin();

      public Result myMethod(String parameter) {
        // Select the first one to match to invoke?
        … = plugins.getPluginFor(parameter);
        // Select multiple ones to invoke?
        … = plugins.getPluginsFor(parameter);
        // Select and fallback to one if none found?
        … = plugins.getPluginFor(parameter, defaultPlugin);
        // Select and throw an exception if none found?
        … = plugins.getPluginsFor(parameter, new RuntimeException());
      }
 }



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
OrderAware
                                 PluginRegistry
                               Respects @Order/Ordered
                                    OAPR.reverse()




© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Bells‘n‘whistles
                                                 FactoryBean
                                               Spring namespace
                                                   Lazy-eval



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Hera


© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Hera
                                         http://hera.synyx.org
                                              Apache 2.0
                                         Soon to be on GitHub



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Spring
                               Integration 2



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
<bean class="….FirstSamplePlugin" />
 <bean class="….SecondSamplePlugin" />

 <int:channel id="input" />
 <int:channel id="output" />

 <int-hera:dynamic-service-activator
   input-channel="input"
   outputChannel="output"
   plugin-type= "….MyPlugin"
   method= "myBusinessMethod"
   delimiter="payload"
   invocation-arguments= "payload" />




© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Demo


© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Take-aways
                             Know your dependencies
                               On every granularity
                             Start as strict as possible
                            Get lenient where necessary


© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Thanks & credits
                               Eoin Woods - Talk @ InfoQ




© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Resources
                                        Sourcecode @ GitHub
                                             Sonargraph




© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.

More Related Content

Viewers also liked

Sophisticated JPA with Spring & Hades
Sophisticated JPA with Spring & HadesSophisticated JPA with Spring & Hades
Sophisticated JPA with Spring & HadesOliver Gierke
 
Spring Roo 1.0.0 Technical Deep Dive
Spring Roo 1.0.0 Technical Deep DiveSpring Roo 1.0.0 Technical Deep Dive
Spring Roo 1.0.0 Technical Deep DiveBen Alex
 
Mylyn - Increasing developer productivity
Mylyn - Increasing developer productivityMylyn - Increasing developer productivity
Mylyn - Increasing developer productivityOliver Gierke
 
Generic DAOs With Hades
Generic DAOs With HadesGeneric DAOs With Hades
Generic DAOs With HadesOliver Gierke
 
Real world dependency injection - DPC10
Real world dependency injection - DPC10Real world dependency injection - DPC10
Real world dependency injection - DPC10Stephan Hochdörfer
 
Spring in action - Hades & Spring Roo
Spring in action - Hades & Spring RooSpring in action - Hades & Spring Roo
Spring in action - Hades & Spring RooOliver Gierke
 
Data Access 2.0? Please welcome, Spring Data!
Data Access 2.0? Please welcome, Spring Data!Data Access 2.0? Please welcome, Spring Data!
Data Access 2.0? Please welcome, Spring Data!Oliver Gierke
 
An introduction into Spring Data
An introduction into Spring DataAn introduction into Spring Data
An introduction into Spring DataOliver Gierke
 
Spring Data JPA - Repositories done right
Spring Data JPA - Repositories done rightSpring Data JPA - Repositories done right
Spring Data JPA - Repositories done rightOliver Gierke
 
Data access 2.0? Please welcome: Spring Data!
Data access 2.0? Please welcome: Spring Data!Data access 2.0? Please welcome: Spring Data!
Data access 2.0? Please welcome: Spring Data!Oliver Gierke
 
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?Whoops! Where did my architecture go?
Whoops! Where did my architecture go?Oliver Gierke
 

Viewers also liked (13)

Sophisticated JPA with Spring & Hades
Sophisticated JPA with Spring & HadesSophisticated JPA with Spring & Hades
Sophisticated JPA with Spring & Hades
 
Spring Roo 1.0.0 Technical Deep Dive
Spring Roo 1.0.0 Technical Deep DiveSpring Roo 1.0.0 Technical Deep Dive
Spring Roo 1.0.0 Technical Deep Dive
 
Mylyn - Increasing developer productivity
Mylyn - Increasing developer productivityMylyn - Increasing developer productivity
Mylyn - Increasing developer productivity
 
Generic DAOs With Hades
Generic DAOs With HadesGeneric DAOs With Hades
Generic DAOs With Hades
 
Mylyn
MylynMylyn
Mylyn
 
Real world dependency injection - DPC10
Real world dependency injection - DPC10Real world dependency injection - DPC10
Real world dependency injection - DPC10
 
Spring in action - Hades & Spring Roo
Spring in action - Hades & Spring RooSpring in action - Hades & Spring Roo
Spring in action - Hades & Spring Roo
 
Data Access 2.0? Please welcome, Spring Data!
Data Access 2.0? Please welcome, Spring Data!Data Access 2.0? Please welcome, Spring Data!
Data Access 2.0? Please welcome, Spring Data!
 
An introduction into Spring Data
An introduction into Spring DataAn introduction into Spring Data
An introduction into Spring Data
 
Spring integration
Spring integrationSpring integration
Spring integration
 
Spring Data JPA - Repositories done right
Spring Data JPA - Repositories done rightSpring Data JPA - Repositories done right
Spring Data JPA - Repositories done right
 
Data access 2.0? Please welcome: Spring Data!
Data access 2.0? Please welcome: Spring Data!Data access 2.0? Please welcome: Spring Data!
Data access 2.0? Please welcome: Spring Data!
 
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
 

Similar to Whoops! Where did my architecture go?

An Introduction to Spring Data
An Introduction to Spring DataAn Introduction to Spring Data
An Introduction to Spring DataOliver Gierke
 
Flash camp portugal - Let's talk about Flex baby
Flash camp portugal - Let's talk about Flex babyFlash camp portugal - Let's talk about Flex baby
Flash camp portugal - Let's talk about Flex babyMichael Chaize
 
Shoretel brilliantly simple_overview
Shoretel brilliantly simple_overviewShoretel brilliantly simple_overview
Shoretel brilliantly simple_overviewChuck Brown
 
Project Controls Expo, 13th Nov 2013 - "Integrated Project Planning/Schedulin...
Project Controls Expo, 13th Nov 2013 - "Integrated Project Planning/Schedulin...Project Controls Expo, 13th Nov 2013 - "Integrated Project Planning/Schedulin...
Project Controls Expo, 13th Nov 2013 - "Integrated Project Planning/Schedulin...Project Controls Expo
 
Converge SE 2011 Building a Strong Foundation
Converge SE 2011 Building a Strong FoundationConverge SE 2011 Building a Strong Foundation
Converge SE 2011 Building a Strong FoundationAaron Quinn
 
Flex presentation for Paris Android User group PAUG
Flex presentation for Paris Android User group PAUGFlex presentation for Paris Android User group PAUG
Flex presentation for Paris Android User group PAUGMichael Chaize
 
スマートフォン対策ビジネスセミナー / Session1:Adobe AIRで実現する超生産的スマートフォンアプリ開発
スマートフォン対策ビジネスセミナー / Session1:Adobe AIRで実現する超生産的スマートフォンアプリ開発スマートフォン対策ビジネスセミナー / Session1:Adobe AIRで実現する超生産的スマートフォンアプリ開発
スマートフォン対策ビジネスセミナー / Session1:Adobe AIRで実現する超生産的スマートフォンアプリ開発Nishiyama Shoichi
 
Sweet dreams of load testing
Sweet dreams of load testing Sweet dreams of load testing
Sweet dreams of load testing Oleg Tatarchuk
 
Oop2012 mobile workshops
Oop2012 mobile workshopsOop2012 mobile workshops
Oop2012 mobile workshopsMichael Chaize
 
engineering mechanics andrew pytelch 11
engineering mechanics andrew pytelch 11engineering mechanics andrew pytelch 11
engineering mechanics andrew pytelch 11BrijeshRai19
 
Using Google Analytics with jQuery Mobile
Using Google Analytics with jQuery MobileUsing Google Analytics with jQuery Mobile
Using Google Analytics with jQuery MobileKoji Ishimoto
 
Jenkins Enterprise by CloudBees Webinar
Jenkins Enterprise by CloudBees WebinarJenkins Enterprise by CloudBees Webinar
Jenkins Enterprise by CloudBees WebinarCloudBees
 
In The Future We All Use Symfony2
In The Future We All Use Symfony2In The Future We All Use Symfony2
In The Future We All Use Symfony2Brent Shaffer
 
Opening opensource : The Jenkins Way
Opening opensource : The Jenkins WayOpening opensource : The Jenkins Way
Opening opensource : The Jenkins WayNicolas De Loof
 
Project Controls Expo, 13th Nov 2013 - "A new visual way to engage executive ...
Project Controls Expo, 13th Nov 2013 - "A new visual way to engage executive ...Project Controls Expo, 13th Nov 2013 - "A new visual way to engage executive ...
Project Controls Expo, 13th Nov 2013 - "A new visual way to engage executive ...Project Controls Expo
 
Reasons for Flash: Flash Development in an HTML5 and App Store World
Reasons for Flash: Flash Development in an HTML5 and App Store WorldReasons for Flash: Flash Development in an HTML5 and App Store World
Reasons for Flash: Flash Development in an HTML5 and App Store WorldEffectiveUI
 
SharePoint2010Integration
SharePoint2010IntegrationSharePoint2010Integration
SharePoint2010IntegrationSlava Gorbunov
 
360iDev OTA Distribution and Build Automation
360iDev OTA Distribution and Build Automation360iDev OTA Distribution and Build Automation
360iDev OTA Distribution and Build AutomationJay Graves
 

Similar to Whoops! Where did my architecture go? (20)

An Introduction to Spring Data
An Introduction to Spring DataAn Introduction to Spring Data
An Introduction to Spring Data
 
Flash camp portugal - Let's talk about Flex baby
Flash camp portugal - Let's talk about Flex babyFlash camp portugal - Let's talk about Flex baby
Flash camp portugal - Let's talk about Flex baby
 
Shoretel brilliantly simple_overview
Shoretel brilliantly simple_overviewShoretel brilliantly simple_overview
Shoretel brilliantly simple_overview
 
Montpellier - Flex UG
Montpellier - Flex UGMontpellier - Flex UG
Montpellier - Flex UG
 
Project Controls Expo, 13th Nov 2013 - "Integrated Project Planning/Schedulin...
Project Controls Expo, 13th Nov 2013 - "Integrated Project Planning/Schedulin...Project Controls Expo, 13th Nov 2013 - "Integrated Project Planning/Schedulin...
Project Controls Expo, 13th Nov 2013 - "Integrated Project Planning/Schedulin...
 
Converge SE 2011 Building a Strong Foundation
Converge SE 2011 Building a Strong FoundationConverge SE 2011 Building a Strong Foundation
Converge SE 2011 Building a Strong Foundation
 
Flex presentation for Paris Android User group PAUG
Flex presentation for Paris Android User group PAUGFlex presentation for Paris Android User group PAUG
Flex presentation for Paris Android User group PAUG
 
Flexpaug 111207121300-phpapp01
Flexpaug 111207121300-phpapp01Flexpaug 111207121300-phpapp01
Flexpaug 111207121300-phpapp01
 
スマートフォン対策ビジネスセミナー / Session1:Adobe AIRで実現する超生産的スマートフォンアプリ開発
スマートフォン対策ビジネスセミナー / Session1:Adobe AIRで実現する超生産的スマートフォンアプリ開発スマートフォン対策ビジネスセミナー / Session1:Adobe AIRで実現する超生産的スマートフォンアプリ開発
スマートフォン対策ビジネスセミナー / Session1:Adobe AIRで実現する超生産的スマートフォンアプリ開発
 
Sweet dreams of load testing
Sweet dreams of load testing Sweet dreams of load testing
Sweet dreams of load testing
 
Oop2012 mobile workshops
Oop2012 mobile workshopsOop2012 mobile workshops
Oop2012 mobile workshops
 
engineering mechanics andrew pytelch 11
engineering mechanics andrew pytelch 11engineering mechanics andrew pytelch 11
engineering mechanics andrew pytelch 11
 
Using Google Analytics with jQuery Mobile
Using Google Analytics with jQuery MobileUsing Google Analytics with jQuery Mobile
Using Google Analytics with jQuery Mobile
 
Jenkins Enterprise by CloudBees Webinar
Jenkins Enterprise by CloudBees WebinarJenkins Enterprise by CloudBees Webinar
Jenkins Enterprise by CloudBees Webinar
 
In The Future We All Use Symfony2
In The Future We All Use Symfony2In The Future We All Use Symfony2
In The Future We All Use Symfony2
 
Opening opensource : The Jenkins Way
Opening opensource : The Jenkins WayOpening opensource : The Jenkins Way
Opening opensource : The Jenkins Way
 
Project Controls Expo, 13th Nov 2013 - "A new visual way to engage executive ...
Project Controls Expo, 13th Nov 2013 - "A new visual way to engage executive ...Project Controls Expo, 13th Nov 2013 - "A new visual way to engage executive ...
Project Controls Expo, 13th Nov 2013 - "A new visual way to engage executive ...
 
Reasons for Flash: Flash Development in an HTML5 and App Store World
Reasons for Flash: Flash Development in an HTML5 and App Store WorldReasons for Flash: Flash Development in an HTML5 and App Store World
Reasons for Flash: Flash Development in an HTML5 and App Store World
 
SharePoint2010Integration
SharePoint2010IntegrationSharePoint2010Integration
SharePoint2010Integration
 
360iDev OTA Distribution and Build Automation
360iDev OTA Distribution and Build Automation360iDev OTA Distribution and Build Automation
360iDev OTA Distribution and Build Automation
 

Recently uploaded

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Recently uploaded (20)

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

Whoops! Where did my architecture go?

  • 1. Whoops! Where did my architecture go? Approaches to architecture management for Java and Spring applications Oliver Gierke © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 2. Oliver Gierke Spring Data Core/JPA/MongoDB ogierke@vmware.com www.olivergierke.de olivergierke © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 3. Background Few years of consulting Lots of code reviews Eoin Woods‘ talk on InfoQ © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 4. Roadmap Architecture 101 A Java packages model Hera © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 5. Architecture 101 © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 6. Know your dependencies © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 7. Granularity Modules Layers Vertical slices Subsystems © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 8. Granularity Java ARchive Package Class © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 9. Of layers and slices… © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 10. Slice A Slice B Slice C Layer 1 Layer 2 Layer 3 © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 11. Layers Well understood Known to developers Less important to business © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 12. Slices Hardly understood New to developers Key for business req © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 13. Slice A Slice B Slice C Layer 1 Layer 2 Layer 3 © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 14. " How to implement an architecture inside a codebase? © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 15. Architecture VS. Codebase © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 16. " How to implement an architecture inside a codebase? © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 17. " How to enforce an architecture inside a codebase? © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 18. Code analysis JDepend Sonar © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 19. Demo © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 20. Sonargraph Formerly known as SonarJ © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 21. Demo © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 22. A plain Java based approach © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 23. Slice A Slice B Slice C Layer 1 Layer 2 Layer 3 © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 24. ….${layer}.${slice} VS. ….${slice}.${layer} © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 25. Layers first Leaks slice internals Lower layers visible to everyone © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 26. " Start with less packages and the least visibility possible… © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 27. Slice A Slice B Slice C Layer 1 Layer 2 Layer 3 © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 28. Slice A Slice B Slice C Layer 1 Layer 2 Layer 3 © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 29. Slices first Start with package per slice Expose interfaces and domain types Keep implementations private © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 30. Slices first Encapsulates business module Internals understood anyway © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 31. Subsystems © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 32. Background Risk mgmt. at German public bank Quite a few other SpringSource clients © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 33. " The smallest plugin system ever! © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 34. Host SPI SPI SPI Plugin Plugin © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 35. Context No OSGi Spring based Build-time composition Don‘t touch the host system © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 36. App Plugin Plugin Host © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 37. " How to make the host aware of the plugins? © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 38. " How to dynami- cally collect Spring beans of a given type? © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 39. classpath*:META-INF/ spring/plugin-context.xml © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 40. classpath*:META-INF/ spring/plugin-context.xml SPI SPI SPI META-INF/spring/ META-INF/spring/ plugin-context.xml plugin-context.xml © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 41. @Component public class MyComponentImpl implements TransferService { private List<MyPlugin> plugins; @Autowired public MyComponentImpl(List<MyPlugin> plugins) { this.plugins = plugins; } … } public interface MyPlugin { void doSomething(); } © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 42. Demo © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 43. XML? Back in the days © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 44. (XML?) Back in the days Probably not a big deal anymore © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 45. Easy access? © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 46. @Component public class MyComponentImpl implements TransferService { private List<MyPlugin> plugins; @Autowired public MyComponentImpl(List<MyPlugin> plugins) { this.plugins = plugins; } … } public interface MyPlugin { void doSomething(); } © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 47. @Component public class MyComponentImpl implements TransferService { // Constructor omitted public Result myMethod(SomeParameter parameter) { // Select the first one to match to invoke? // Select multiple ones to invoke? // Select and fallback to one if none found? // Select and throw an exception if none found? } } © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 48. Plugins Selection criterion Callback method Let the implementation decide © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 49. Registry Equipped with plugins Common access patterns © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 50. public interface Plugin<T> { public boolean supports(T delimiter ); } public interface PluginRegistry<S extends Plugin<T>, T> { T getPluginFor(S delimiter); T getPluginFor(S delimiter, T default); <E extends Exception> T getPluginFor(S del, E exception) throws E; List<T> getPluginsFor(S delimiter); … } © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 51. @Component public class MyComponentImpl implements TransferService { private PluginRegistry<MyPlugin, String> plugins; @Autowired public MyComponentImpl(PluginRegistry<MyPlugin, String> plugins) { this.plugins = plugins; } … } public interface MyPlugin extends Plugin<String> { void doSomething(); } © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 52. @Component public class MyComponentImpl implements TransferService { private final MyPlugin defaultPlugin = new MyDefaultPlugin(); public Result myMethod(String parameter) { // Select the first one to match to invoke? … = plugins.getPluginFor(parameter); // Select multiple ones to invoke? … = plugins.getPluginsFor(parameter); // Select and fallback to one if none found? … = plugins.getPluginFor(parameter, defaultPlugin); // Select and throw an exception if none found? … = plugins.getPluginsFor(parameter, new RuntimeException()); } } © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 53. OrderAware PluginRegistry Respects @Order/Ordered OAPR.reverse() © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 54. Bells‘n‘whistles FactoryBean Spring namespace Lazy-eval © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 55. Hera © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 56. Hera http://hera.synyx.org Apache 2.0 Soon to be on GitHub © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 57. Spring Integration 2 © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 58. <bean class="….FirstSamplePlugin" /> <bean class="….SecondSamplePlugin" /> <int:channel id="input" /> <int:channel id="output" /> <int-hera:dynamic-service-activator input-channel="input" outputChannel="output" plugin-type= "….MyPlugin" method= "myBusinessMethod" delimiter="payload" invocation-arguments= "payload" /> © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 59. Demo © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 60. Take-aways Know your dependencies On every granularity Start as strict as possible Get lenient where necessary © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 61. Thanks & credits Eoin Woods - Talk @ InfoQ © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 62. Resources Sourcecode @ GitHub Sonargraph © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.