SlideShare a Scribd company logo
1 of 68
Download to read offline
1
Modular Architecture Today




     Kirk Knoernschild
         @pragkirk



                             2
Java Application Architecture
                               Modularity Patterns with Examples Using OSGi


Forewords by Robert C. Martin and Peter Kriens
     I’m dancing! By god I’m dancing on the walls. I’m dancing on the ceiling. I’m
     ecstatic. I’m overjoyed. I’m really, really pleased.”
         - From the Foreword by Robert C. Martin (a.k.a. Uncle Bob)

Java Application Architecture will help you

  ‣Design modular software that is extensible, reusable, maintainable, and adaptable
  ‣Design modular software today, in anticipation of platform support for modularity
  ‣Break large software systems into a flexible composite of collaborating modules
  ‣Understand where to place your architectural focus
  ‣Migrate large-scale monolithic applications to applications with a modular architecture
  ‣Articulate the advantages of modular software to your team

                              Visit http://modularity.kirkk.com for more information.
                                                                                             3
The Code

https://github.com/pragkirk/poma/network



       or just Google   pragkirk github




                                           4
Goals Today

    2 Simple Goals Today
  1.) Start designing modular software tomorrow!


   2.) Don’t flip the bit on OSGi as too complex!




                                                   5
Modular Architecture Today

      Introducing Modularity
     The Modularity Patterns
     Refactor to Modularity
         Introducing OSGi
         OSGi-ify the App
                               6
Agile Architecture

            Introducing Modularity
                                                                 What
                                                                        ch
      What                           Why i
                                             s mo d             us to d allenges fac
             are th                                 ula                ay in           e
                   e ben            neces                                    design
      mo dul
            arity?       efits o             sar y c rity a      mo dul
                                                                      ar sof        ing
                                f   ag ile         o mpon                   tware
                                           archit         en                      ?
                                                  ecture t of
                                                        ?




                                                                                           7
Modularity - Not New!




                                1972        (or a bit before)




On The Criteria To Be Used in Decomposing Systems into Modules
  by David Parnas at http://www.cs.umd.edu/class/spring2003/cmsc838p/Design/criteria.pdf


                                                                                           8
Defining Module
                   Hey, it’s a JAR file!

                                              - unit
                                                      of reu
                                             - unit          se
                                                     of co m
                                            - unit           po
                                                    of dep sition
                                           - unit          loyme
                                                   of ma         nt
                                                          nagem
                                                                ent




      A module system provides a runtime environment for modules




                                                                      9
The Facets
        Runtime                                      Development

       Infras                       Progr                            Desig
             tructu                      am   ming                         n   Para dThink    about when
                       re                            Mo de                           igm
                                                              l
       Runtim                      The fr                            The te            you started using
              e plat                     amew                                 chniqu
      suppo           for m       techn          o r ks a
                                                         nd         to i de          esobjects! Using the
                                                                                        use d
            rt hel                      olog ie                             ntify
     enforc        ps            allow          s that             create         an d language constructs
            e mo d                      us to                                the ri
    archit          ular         mo dul        create             o f mo           ghtwere easy, but
          ecture                       ar sof                             dules         set
                  .                           tware
                                                                                       creating designs
                                                                                       was still really hard.

                               The Design Paradigm
                       - What’s the right granularity for a module?
                          - What the right weight for a module?
                                                                                                   demo
                                                                                                           10
Paradox

                                                                                   Increa
                                                                                          sing e
                                                                                  decre         volvab
                                                                                        ases s           ility
                                                                                               ur viva
                                                                                                       bility
            (Reuse,
          Compose,
           Extend,
         Lightweight,
       Fine-Grained, ...)



                                  (Use, Maintain, Understand, ...)



 ... making everything easy to change makes the entire system very
                              complex...
                                    - Ralph Johnson in “Who Needs an Architect”


                                                                                                                 11
Architectural Joints or Seams
                                       Here?



     Which                                             Here?
   system area of the
          deman
                   ds mo
        flexib            re
              ility?
                               Here?                    Here?




                              Here?                      Here?

                                               Here?

                                                                 12
Complexity and Knowledge




    Source: http://www.tensegrity.hellblazer.com/   Source: http://adaptevolve.blogspot.com/



                                                                                               13
Complexity, Knowledge, & Modularity




                                      14
demo
Architectural Joints or Seams
                                         Here?



       Which                                             Here?
     system area of the
            deman
                     ds mo
          flexib            re
                ility?
                                 Here?                    Here?




 Modularizing software          Here?                      Here?
 affects our design in
 interesting ways.
                                                 Here?

                                                                      15
Benefits of Modularity

    - reus
           e                    Increases architectural agility!
   - re du
           ce co m
  - ease          ple
           mainte xity
 - incr           nance
        ease
exten
       sibility




Umm...we can already do this with objects, aspects, methods, and services!


                                                                             16
All the Way Down



          ?

                        Reuse Release Equivalence:
                   Unit of reuse is the unit of release!


                                                           17
Agile Architecture

       The Modularity Patterns

                What
                       are th
                mo dul        e
                      arity
                            patter
                                   ns?




                                         18
Base Patterns
 • Manage Relationships – Design Module Relationships.
 • Module Reuse – Emphasize reusability at the module level.
 • Cohesive Modules – Module behavior should serve a singular
   purpose.




                                                                19
Dependency Patterns
 • Acyclic Relationships - Module relationships must be acyclic.
 • Levelize Modules – Module relationships should be levelized.
 • Physical Layers - Module relationships should not violate the
     conceptual layers.
 •   Container Independence - Modules should be independent of
     the runtime container.
 •   Independent Deployment - Modules should be independently
     deployable units.


                                                                   20
Usability Patterns
 • Published Interface - Make a module’s published interface well
     known.
 •   External Configuration – Modules should be externally
     configurable.
 •   Default Implementation - Provide modules with a default
     implementation.
 •   Module Facade – Create a facade serving as a coarse-grained
     entry point to another fine-grained module’s underlying
     implementation.

                                                                    21
Extensibility Patterns
 • Abstract Modules - Depend upon the abstract elements of a
     module.
 •   Implementation Factory - Use factories to create a module’s
     implementation classes.
 •   Separate Abstractions - Place abstractions and the classes that
     implement them in separate modules.




                                                                       22
Utility Patterns
 • Colocate Exceptions: Exceptions should be close to the class or
     interface that throws them.
 •   Levelize Build – Execute the build in accordance with module
     levelization.
 •   Test Module – Each module should have a corresponding test
     module.




                                                                     23
Agile Architecture


          Patterns Applied
           Ho w c                     Ho w d                   This is the Design
                  an I u                    o they
           mo dul
                 arity
                         se the      acco m          h
                                            mo dat elp         Paradigm
                       patter       archit        e
                              ns?          ectura
                                                  l shift
                                                          s?




                                                                                    24
The System

     Design a system to handle payment and auditing of
     various types of bills. The system must integrate with
     3rd party auditing software, and a legacy financials
     system that must be fed payment information for
     reconciliation.




                                                              25
The Class Model

 Note t
          he bi-
 a sso ci        direct
         ations         ional
               !




                                26
demo
Initial Systems Modules

                              If I la
                                      ye
                              but no r conceptua
                                     t phys         lly
                             then a         ically,
                                    m
                            the a d I realizing
                                   vantag
                           layeri          e
                                  ng? W s of
                          layer ?        hy do
                                                I




                                                             27
Physical Layers
       Module relationships should not violate the conceptual layers.




                                                                        28
Abstract Modules
                   Depend upon the abstract elements of a module.
                                                                package client;
                                                                import service.*;
                                                                public class Client {
                                                                  Service service;
                                                                }


                                                                package service;

                                                                public interface Service {
                                                                  public void doService();
                                                                }
        - “Inje
                 ct
       implem ” the                                             package service;
                entati
      Client.         on int
                             o                                  public class ServiceImpl implements
     - “ Lo o
              ku p                                              Service {
    implem ” the
              entati                                              public void doService() {
    Client.         on w it
                            hin                                      ....
                                                                  };
                                                                }

                                                                                                      29
Abstract Modules

        What
              if
       to use Bill must be
              differ
      system        ent au able
             s?           diting




                                   30
Abstract Modules




                    Au ditF
                            aca de
                   into B          1 is in
                          ill as           jecte d
                   Au ditF       an
                          aca de
                                  type.




                                                     31
Abstract Modules




                   32
Acyclic Relationships
        Module relationships must be acyclic




                                               33
Recall - Abstract Modules




                                    Au ditF
                                            aca de
                                   into B          1 is in
                                          ill as           jecte d
                                   Au ditF       an
                                          aca de
                                                  type.




               Same problem here

                                                                     34
Recall - Abstract Modules




                            35
Uni-Directional




                  36
demo
Acyclic Relationships




                           37
Separate Abtractions
       Separate abstractions from the classes that realize them.

      How d
              o I in
      with a         tegra
                           te
             nothe
     auditi        r
            ng sy
                 stem?
    Wher
           e doe
                 s
    Audit
          Facad
                e2 liv
                       e?




                                                                   38
Separate Abstractions

      Shoul
             d I p
                  ut
      Audit
            Facad
                  e2 i n
     audit.
           jar?




                           39
Separate Abstractions




                        40
Colocate Exceptions
                     Exceptions should be close to the classes that throw them


     Audit
              Facad
                    e thro
     the A                ws
             uditEx
                    ceptio
                           n.




                                                                   Exception goes here.

                                                                                          41
Independent Deployment
   Modules should be independently deployable units.


              How d
                      o I re
             bill.ja          use
                     r wi t h
            financ           out
                    ial.ja
                           r? Lik
           a bat                  e in
                  ch ap
                         plicat
                                ion?




                                                       42
Independent Deployment




                         43
Independent Deployment
                    1.) PayAction invokes Bill.pay()
                    and passes BillPayAdapter
                    as a BillPayer.
                    2.) Bill.pay() invokes
                    BillPayer.generateDraft()
                    3.)BillPayAdapeter.generateDraft()
                    invokes Payment.generateDraft()
                    passing itself as a Payable.
                    4.) Payment.generateDraft()
                    invokes Payable.getAmount()




                                                         44
Independent Deployment




                         45
Implementation Factory
       Use factories to create a modules implementation classes.




                                                                   46
demo
The Final Structure




                         47
Opportunities




                48
Modular Architecture Today

                       Introducing OSGi?

                                                                This is the
                        Is OS
    What
           is OSG
                             Gi   new?   Who i
                                              s usin            Infrastructure &
                  i?                                 g OSG
                                                           i?   Programming
                                                                Model




                                                                              49
Modularity is coming to the Java platform!




OpenJDK




                                              50
A Bit of History
 • JSR 8 - Open Services Gateway specification in 1999 (JSR 232
     or JSR 291)
  •   Gateway for providing services to home devices
  •   lifecycle management, dependencies, installing, versioning, configuration
 • OSGi Alliance formed in 1999 and delivered V1.0 in 2000
 • Very popular on the desktop; driven by Eclipse 3.0 adoption in
     2003
 •   Today, just about all Java middleware products use OSGi
  •   WAS, WebLogic, GlassFish, Paremus Service Fabric, JBoss, Geronimo, ...

                                                                                 51
Introducing OSGi
   Dynamic Module System for Java
 ClassLoaders
 - Each bundle has it’s own classloader and it’s own
 lifecycle

 µServices
 - Bundle exposes it’s
 behavior via well-defined
 interface
                                                       MODULE
 Bundles
 - Bundle is a JAR file with
 manifest


                                                                52
A Valid Bundle
              myjar.jar                                   Manifest.mf
                                     Manifest-Version: 1.0
                                     Bundle-ManifestVersion: 2
                                     Bundle-Name: Scala Calculator

                     JAR
                           +         Bundle-SymbolicName: scala calculator
                                     Bundle-Version: 1.0.0
                                     Import-Package:
                                     com.extensiblejava.loan,scala.annotation.unchecked;us
                                     es:="scala.reflect,scala"
                                      ;version="2.8.0.final"

<osgi:service id="LoanCalculator" ref="loanCalculator"
interface="com.extensiblejava.loan.LoanCalculator"/>   Register µServices
<osgi:reference id="paymentFactory"                    µService Reference
interface="com.extensiblejava.loan.PaymentFactory"/>

                                                                                         53
The Basic Workings
                        Private packages      Classloader restricts
                       are implementation            visibility


          Imported                           Exported
          packages                           packages



                                                    Publishes the
                           JAR is a module       interface, ideally as
      Classloader gives                               µServices
     each module its own
                                 DYNAMICITY
          lifecycle

                                                                         54
Modules as First Class Citizens

       INSTALLED            STARTING


                    start              Because bundles have their
                                       own classloader, they can be
                                         managed independently.
       RESOLVED              ACTIVE      Hence, a very dynamic
                                              environment.

                                stop


      UNINSTALLED           STOPPING



                                                                      55
demo
The Runtime

                 - Dyn
                       ami
                - Mult c deployme
                       ipl             nt
               - Enfo e versions
                      rce de
              - Enca         pen de
                     psulat         ncies
                            ion




                                               56
demo
Too Complex?

“OSGi provides little value and is too complex as demonstrated by our failed attempt to make
modularity invisible when porting our legacy system to it with over 150 third-party JARs.
-- http://blogs.mulesoft.org/osgi-no-thanks



“OSGi is a great solution for complex applications with stringent modularity requirements.”
-- http://www.theserverside.com/news/thread.tss?thread_id=62590




                                                                                                  57
A Modular System TODAY!




                          58
Standard Java Lack Encapsulation




                            Everything is still
                          visible; no dynamics!




                                              59
No Encapsulation




                   60
Type Visibility


              Any public class in any JAR on the classpath can be seen by any
                                other class on the classpath!




                      With OSGi, you have control who sees what!




                                        Cookie Jar images courtesy of Richard Hall


                                                                                     61
Not Visible




              62
demo
Encapsulation




                Nothing can reach this
                        class!

                                         63
Modularity Today
   Platforms discourage modularity!    Why a
                                              re
                                      design n’t we
                                             in
                                      mo dul g more
                                            ar sof
                                                  tware
                                                        ?




                                                            64
demo
Modularity Tomorrow
  This is the next generation application platform!
                                                        - Dyn
                                                              ami
                                                       - Mult c deployme
                                                              ipl             nt
                                                      - Expl e versions
                                                            icit de
                                                                    pen de
                                                                           ncies




                                                                                      65
Modular Architecture Today

                            OSGi-ify the App

      Ho w d
             o I bu              Is it i                         Is it r
      applic        ild                 nvasiv                          eally
            ations                            e to m                            to o co
                   using                             y co de                            mplex
                         OSGi?                               ?                               ?




                                                                                                 66
Java Application Architecture
                               Modularity Patterns with Examples Using OSGi


Forewords by Robert C. Martin and Peter Kriens
     I’m dancing! By god I’m dancing on the walls. I’m dancing on the ceiling. I’m
     ecstatic. I’m overjoyed. I’m really, really pleased.”
         - From the Foreword by Robert C. Martin (a.k.a. Uncle Bob)

Java Application Architecture will help you

  ‣Design modular software that is extensible, reusable, maintainable, and adaptable
  ‣Design modular software today, in anticipation of platform support for modularity
  ‣Break large software systems into a flexible composite of collaborating modules
  ‣Understand where to place your architectural focus
  ‣Migrate large-scale monolithic applications to applications with a modular architecture
  ‣Articulate the advantages of modular software to your team

                              Visit http://modularity.kirkk.com for more information.
                                                                                             67
Q&A

      68

More Related Content

What's hot

Deconstructivism
DeconstructivismDeconstructivism
Deconstructivism
azimkhtr
 

What's hot (20)

Principle of architecture
Principle of architecturePrinciple of architecture
Principle of architecture
 
Architectural Design Process for Beginners/Students
Architectural Design Process for Beginners/StudentsArchitectural Design Process for Beginners/Students
Architectural Design Process for Beginners/Students
 
Animateform
Animateform Animateform
Animateform
 
Post Modern Architecture
Post Modern ArchitecturePost Modern Architecture
Post Modern Architecture
 
Theory of design - types of design
Theory of design - types of designTheory of design - types of design
Theory of design - types of design
 
form follows function!
form follows function!form follows function!
form follows function!
 
Constructivism
ConstructivismConstructivism
Constructivism
 
HIstory of Architecture: The Elements of Architecture & Architecture in Civil...
HIstory of Architecture: The Elements of Architecture & Architecture in Civil...HIstory of Architecture: The Elements of Architecture & Architecture in Civil...
HIstory of Architecture: The Elements of Architecture & Architecture in Civil...
 
WORKS OF BV DOSHI
WORKS OF BV DOSHI WORKS OF BV DOSHI
WORKS OF BV DOSHI
 
Futurism Architecture
Futurism ArchitectureFuturism Architecture
Futurism Architecture
 
Mohammad Shaheer | Landscape design
Mohammad Shaheer | Landscape design Mohammad Shaheer | Landscape design
Mohammad Shaheer | Landscape design
 
Presentation1 plane-FORM SPACE AND ORDER
Presentation1 plane-FORM SPACE AND ORDERPresentation1 plane-FORM SPACE AND ORDER
Presentation1 plane-FORM SPACE AND ORDER
 
Guggenheim Museum Bilbao
Guggenheim Museum BilbaoGuggenheim Museum Bilbao
Guggenheim Museum Bilbao
 
Deconstructivism
DeconstructivismDeconstructivism
Deconstructivism
 
Tod principle of architecture
Tod principle of architectureTod principle of architecture
Tod principle of architecture
 
Berlin museum
Berlin museumBerlin museum
Berlin museum
 
Achyut kanvinde
Achyut kanvindeAchyut kanvinde
Achyut kanvinde
 
The Maxxi Museum
The Maxxi Museum The Maxxi Museum
The Maxxi Museum
 
Geometry concepts in architectural design
Geometry concepts in architectural designGeometry concepts in architectural design
Geometry concepts in architectural design
 
Marcos novak idea,philosophy and works
Marcos novak idea,philosophy and worksMarcos novak idea,philosophy and works
Marcos novak idea,philosophy and works
 

Viewers also liked

#6a modular construction (1)
#6a    modular construction (1)#6a    modular construction (1)
#6a modular construction (1)
Eveana Crystle
 
10 key words for architecture
10 key words for architecture10 key words for architecture
10 key words for architecture
ceiprosachacel
 
Software design principles
Software design principlesSoftware design principles
Software design principles
Ritesh Singh
 
modelingtools
modelingtoolsmodelingtools
modelingtools
learnt
 

Viewers also liked (20)

Modular Architectures: What they are why do they matter now.
Modular Architectures: What they are why do they matter now.Modular Architectures: What they are why do they matter now.
Modular Architectures: What they are why do they matter now.
 
ZF2 Modular Architecture - Taking advantage of it
ZF2 Modular Architecture - Taking advantage of itZF2 Modular Architecture - Taking advantage of it
ZF2 Modular Architecture - Taking advantage of it
 
Product Architecture
Product ArchitectureProduct Architecture
Product Architecture
 
#6a modular construction (1)
#6a    modular construction (1)#6a    modular construction (1)
#6a modular construction (1)
 
10 key words for architecture
10 key words for architecture10 key words for architecture
10 key words for architecture
 
COMMERCIAL MODULAR ARCHITECTURE
COMMERCIAL MODULAR ARCHITECTURECOMMERCIAL MODULAR ARCHITECTURE
COMMERCIAL MODULAR ARCHITECTURE
 
Software design principles
Software design principlesSoftware design principles
Software design principles
 
Modular Building Institute Report
Modular Building Institute ReportModular Building Institute Report
Modular Building Institute Report
 
modelingtools
modelingtoolsmodelingtools
modelingtools
 
Tips and Tricks for Automating Windows with Chef
Tips and Tricks for Automating Windows with ChefTips and Tricks for Automating Windows with Chef
Tips and Tricks for Automating Windows with Chef
 
Software Architecture Taxonomies - modularity
Software Architecture Taxonomies - modularitySoftware Architecture Taxonomies - modularity
Software Architecture Taxonomies - modularity
 
MT23 Benefits of Modular Computing from Data Center to Branch Office
MT23 Benefits of Modular Computing from Data Center to Branch OfficeMT23 Benefits of Modular Computing from Data Center to Branch Office
MT23 Benefits of Modular Computing from Data Center to Branch Office
 
MT25 Server technology trends, workload impacts, and the Dell Point of View
MT25 Server technology trends, workload impacts, and the Dell Point of ViewMT25 Server technology trends, workload impacts, and the Dell Point of View
MT25 Server technology trends, workload impacts, and the Dell Point of View
 
Bojan Veljanovski - Modular Software Architecture and Design (Code Camp 2016)
Bojan Veljanovski - Modular Software Architecture and Design (Code Camp 2016)Bojan Veljanovski - Modular Software Architecture and Design (Code Camp 2016)
Bojan Veljanovski - Modular Software Architecture and Design (Code Camp 2016)
 
David Goulden keynote at Dell EMC World
David Goulden keynote at Dell EMC WorldDavid Goulden keynote at Dell EMC World
David Goulden keynote at Dell EMC World
 
High rise structure & core
High rise  structure & coreHigh rise  structure & core
High rise structure & core
 
High Rise Building Research Document
High Rise Building Research DocumentHigh Rise Building Research Document
High Rise Building Research Document
 
Mumbai High Rise Buildings Case studies of Kohinoor Square, Aquaria Grande, K...
Mumbai High Rise Buildings Case studies of Kohinoor Square, Aquaria Grande, K...Mumbai High Rise Buildings Case studies of Kohinoor Square, Aquaria Grande, K...
Mumbai High Rise Buildings Case studies of Kohinoor Square, Aquaria Grande, K...
 
High-rise structural systems
High-rise structural systemsHigh-rise structural systems
High-rise structural systems
 
Pre stressed concrete- modular construction technology
Pre stressed concrete- modular construction technologyPre stressed concrete- modular construction technology
Pre stressed concrete- modular construction technology
 

Similar to Modular architecture today

OSGi in the Enterprise: Agility, Modularity, and Architecture's Paradox
OSGi in the Enterprise: Agility, Modularity, and Architecture's ParadoxOSGi in the Enterprise: Agility, Modularity, and Architecture's Paradox
OSGi in the Enterprise: Agility, Modularity, and Architecture's Paradox
pragkirk
 
Hive solutions cloudviews 2010 presentation
Hive solutions cloudviews 2010 presentationHive solutions cloudviews 2010 presentation
Hive solutions cloudviews 2010 presentation
EuroCloud
 
Reverse engineering
Reverse engineeringReverse engineering
Reverse engineering
Saswat Padhi
 
Building a DevOps Team that isn't Evil
Building a DevOps Team that isn't EvilBuilding a DevOps Team that isn't Evil
Building a DevOps Team that isn't Evil
IBM UrbanCode Products
 
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open Wide
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open WideOCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open Wide
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open Wide
OCCIware
 
Track2 -刘希斌----c ie-net-openstack-2012-apac
Track2 -刘希斌----c ie-net-openstack-2012-apacTrack2 -刘希斌----c ie-net-openstack-2012-apac
Track2 -刘希斌----c ie-net-openstack-2012-apac
OpenCity Community
 
Testingonandroid v2-091203161835-phpapp02
Testingonandroid v2-091203161835-phpapp02Testingonandroid v2-091203161835-phpapp02
Testingonandroid v2-091203161835-phpapp02
Gustavo Fuentes Zurita
 
Testingonandroid v2-091203161835-phpapp02
Testingonandroid v2-091203161835-phpapp02Testingonandroid v2-091203161835-phpapp02
Testingonandroid v2-091203161835-phpapp02
Gustavo Fuentes Zurita
 

Similar to Modular architecture today (20)

OSGi in the Enterprise: Agility, Modularity, and Architecture's Paradox
OSGi in the Enterprise: Agility, Modularity, and Architecture's ParadoxOSGi in the Enterprise: Agility, Modularity, and Architecture's Paradox
OSGi in the Enterprise: Agility, Modularity, and Architecture's Paradox
 
Introduction to design specifications to Summer of Code NZ students
Introduction to design specifications to Summer of Code NZ studentsIntroduction to design specifications to Summer of Code NZ students
Introduction to design specifications to Summer of Code NZ students
 
Paremus Cloud and OSGi Beyond the VM - OSGi Cloud Workshop March 2012
Paremus Cloud and OSGi Beyond the VM - OSGi Cloud Workshop March 2012Paremus Cloud and OSGi Beyond the VM - OSGi Cloud Workshop March 2012
Paremus Cloud and OSGi Beyond the VM - OSGi Cloud Workshop March 2012
 
Hive solutions cloudviews 2010 presentation
Hive solutions cloudviews 2010 presentationHive solutions cloudviews 2010 presentation
Hive solutions cloudviews 2010 presentation
 
colony framework & omni platform
colony framework & omni platformcolony framework & omni platform
colony framework & omni platform
 
Reverse engineering
Reverse engineeringReverse engineering
Reverse engineering
 
Agile Engineering Environment (Agile Tour 2009 Chengdu)
Agile Engineering Environment (Agile Tour 2009 Chengdu)Agile Engineering Environment (Agile Tour 2009 Chengdu)
Agile Engineering Environment (Agile Tour 2009 Chengdu)
 
Building a DevOps Team that isn't Evil
Building a DevOps Team that isn't EvilBuilding a DevOps Team that isn't Evil
Building a DevOps Team that isn't Evil
 
A classification framework for component models
A classification framework for component modelsA classification framework for component models
A classification framework for component models
 
The Lean Tech Stack
The Lean Tech StackThe Lean Tech Stack
The Lean Tech Stack
 
Story of Puppet @eBay Global Classifieds Group (eCG)
Story of Puppet @eBay Global Classifieds Group (eCG)Story of Puppet @eBay Global Classifieds Group (eCG)
Story of Puppet @eBay Global Classifieds Group (eCG)
 
EclipseCon 2016 - OCCIware : one Cloud API to rule them all
EclipseCon 2016 - OCCIware : one Cloud API to rule them allEclipseCon 2016 - OCCIware : one Cloud API to rule them all
EclipseCon 2016 - OCCIware : one Cloud API to rule them all
 
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open Wide
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open WideOCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open Wide
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open Wide
 
What's new in CQ 5.3? Top 10 features.
What's new in CQ 5.3? Top 10 features.What's new in CQ 5.3? Top 10 features.
What's new in CQ 5.3? Top 10 features.
 
VRE Definition And Creation
VRE Definition And CreationVRE Definition And Creation
VRE Definition And Creation
 
Track2 -刘希斌----c ie-net-openstack-2012-apac
Track2 -刘希斌----c ie-net-openstack-2012-apacTrack2 -刘希斌----c ie-net-openstack-2012-apac
Track2 -刘希斌----c ie-net-openstack-2012-apac
 
Challenges in Maintaining a High Performance Search Engine Written in Java
Challenges in Maintaining a High Performance Search Engine Written in JavaChallenges in Maintaining a High Performance Search Engine Written in Java
Challenges in Maintaining a High Performance Search Engine Written in Java
 
Testing on Android
Testing on AndroidTesting on Android
Testing on Android
 
Testingonandroid v2-091203161835-phpapp02
Testingonandroid v2-091203161835-phpapp02Testingonandroid v2-091203161835-phpapp02
Testingonandroid v2-091203161835-phpapp02
 
Testingonandroid v2-091203161835-phpapp02
Testingonandroid v2-091203161835-phpapp02Testingonandroid v2-091203161835-phpapp02
Testingonandroid v2-091203161835-phpapp02
 

Recently uploaded

Recently uploaded (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

Modular architecture today

  • 1. 1
  • 2. Modular Architecture Today Kirk Knoernschild @pragkirk 2
  • 3. Java Application Architecture Modularity Patterns with Examples Using OSGi Forewords by Robert C. Martin and Peter Kriens I’m dancing! By god I’m dancing on the walls. I’m dancing on the ceiling. I’m ecstatic. I’m overjoyed. I’m really, really pleased.” - From the Foreword by Robert C. Martin (a.k.a. Uncle Bob) Java Application Architecture will help you ‣Design modular software that is extensible, reusable, maintainable, and adaptable ‣Design modular software today, in anticipation of platform support for modularity ‣Break large software systems into a flexible composite of collaborating modules ‣Understand where to place your architectural focus ‣Migrate large-scale monolithic applications to applications with a modular architecture ‣Articulate the advantages of modular software to your team Visit http://modularity.kirkk.com for more information. 3
  • 4. The Code https://github.com/pragkirk/poma/network or just Google pragkirk github 4
  • 5. Goals Today 2 Simple Goals Today 1.) Start designing modular software tomorrow! 2.) Don’t flip the bit on OSGi as too complex! 5
  • 6. Modular Architecture Today Introducing Modularity The Modularity Patterns Refactor to Modularity Introducing OSGi OSGi-ify the App 6
  • 7. Agile Architecture Introducing Modularity What ch What Why i s mo d us to d allenges fac are th ula ay in e e ben neces design mo dul arity? efits o sar y c rity a mo dul ar sof ing f ag ile o mpon tware archit en ? ecture t of ? 7
  • 8. Modularity - Not New! 1972 (or a bit before) On The Criteria To Be Used in Decomposing Systems into Modules by David Parnas at http://www.cs.umd.edu/class/spring2003/cmsc838p/Design/criteria.pdf 8
  • 9. Defining Module Hey, it’s a JAR file! - unit of reu - unit se of co m - unit po of dep sition - unit loyme of ma nt nagem ent A module system provides a runtime environment for modules 9
  • 10. The Facets Runtime Development Infras Progr Desig tructu am ming n Para dThink about when re Mo de igm l Runtim The fr The te you started using e plat amew chniqu suppo for m techn o r ks a nd to i de esobjects! Using the use d rt hel olog ie ntify enforc ps allow s that create an d language constructs e mo d us to the ri archit ular mo dul create o f mo ghtwere easy, but ecture ar sof dules set . tware creating designs was still really hard. The Design Paradigm - What’s the right granularity for a module? - What the right weight for a module? demo 10
  • 11. Paradox Increa sing e decre volvab ases s ility ur viva bility (Reuse, Compose, Extend, Lightweight, Fine-Grained, ...) (Use, Maintain, Understand, ...) ... making everything easy to change makes the entire system very complex... - Ralph Johnson in “Who Needs an Architect” 11
  • 12. Architectural Joints or Seams Here? Which Here? system area of the deman ds mo flexib re ility? Here? Here? Here? Here? Here? 12
  • 13. Complexity and Knowledge Source: http://www.tensegrity.hellblazer.com/ Source: http://adaptevolve.blogspot.com/ 13
  • 14. Complexity, Knowledge, & Modularity 14
  • 15. demo Architectural Joints or Seams Here? Which Here? system area of the deman ds mo flexib re ility? Here? Here? Modularizing software Here? Here? affects our design in interesting ways. Here? 15
  • 16. Benefits of Modularity - reus e Increases architectural agility! - re du ce co m - ease ple mainte xity - incr nance ease exten sibility Umm...we can already do this with objects, aspects, methods, and services! 16
  • 17. All the Way Down ? Reuse Release Equivalence: Unit of reuse is the unit of release! 17
  • 18. Agile Architecture The Modularity Patterns What are th mo dul e arity patter ns? 18
  • 19. Base Patterns • Manage Relationships – Design Module Relationships. • Module Reuse – Emphasize reusability at the module level. • Cohesive Modules – Module behavior should serve a singular purpose. 19
  • 20. Dependency Patterns • Acyclic Relationships - Module relationships must be acyclic. • Levelize Modules – Module relationships should be levelized. • Physical Layers - Module relationships should not violate the conceptual layers. • Container Independence - Modules should be independent of the runtime container. • Independent Deployment - Modules should be independently deployable units. 20
  • 21. Usability Patterns • Published Interface - Make a module’s published interface well known. • External Configuration – Modules should be externally configurable. • Default Implementation - Provide modules with a default implementation. • Module Facade – Create a facade serving as a coarse-grained entry point to another fine-grained module’s underlying implementation. 21
  • 22. Extensibility Patterns • Abstract Modules - Depend upon the abstract elements of a module. • Implementation Factory - Use factories to create a module’s implementation classes. • Separate Abstractions - Place abstractions and the classes that implement them in separate modules. 22
  • 23. Utility Patterns • Colocate Exceptions: Exceptions should be close to the class or interface that throws them. • Levelize Build – Execute the build in accordance with module levelization. • Test Module – Each module should have a corresponding test module. 23
  • 24. Agile Architecture Patterns Applied Ho w c Ho w d This is the Design an I u o they mo dul arity se the acco m h mo dat elp Paradigm patter archit e ns? ectura l shift s? 24
  • 25. The System Design a system to handle payment and auditing of various types of bills. The system must integrate with 3rd party auditing software, and a legacy financials system that must be fed payment information for reconciliation. 25
  • 26. The Class Model Note t he bi- a sso ci direct ations ional ! 26
  • 27. demo Initial Systems Modules If I la ye but no r conceptua t phys lly then a ically, m the a d I realizing vantag layeri e ng? W s of layer ? hy do I 27
  • 28. Physical Layers Module relationships should not violate the conceptual layers. 28
  • 29. Abstract Modules Depend upon the abstract elements of a module. package client; import service.*; public class Client { Service service; } package service; public interface Service { public void doService(); } - “Inje ct implem ” the package service; entati Client. on int o public class ServiceImpl implements - “ Lo o ku p Service { implem ” the entati public void doService() { Client. on w it hin .... }; } 29
  • 30. Abstract Modules What if to use Bill must be differ system ent au able s? diting 30
  • 31. Abstract Modules Au ditF aca de into B 1 is in ill as jecte d Au ditF an aca de type. 31
  • 33. Acyclic Relationships Module relationships must be acyclic 33
  • 34. Recall - Abstract Modules Au ditF aca de into B 1 is in ill as jecte d Au ditF an aca de type. Same problem here 34
  • 35. Recall - Abstract Modules 35
  • 38. Separate Abtractions Separate abstractions from the classes that realize them. How d o I in with a tegra te nothe auditi r ng sy stem? Wher e doe s Audit Facad e2 liv e? 38
  • 39. Separate Abstractions Shoul d I p ut Audit Facad e2 i n audit. jar? 39
  • 41. Colocate Exceptions Exceptions should be close to the classes that throw them Audit Facad e thro the A ws uditEx ceptio n. Exception goes here. 41
  • 42. Independent Deployment Modules should be independently deployable units. How d o I re bill.ja use r wi t h financ out ial.ja r? Lik a bat e in ch ap plicat ion? 42
  • 44. Independent Deployment 1.) PayAction invokes Bill.pay() and passes BillPayAdapter as a BillPayer. 2.) Bill.pay() invokes BillPayer.generateDraft() 3.)BillPayAdapeter.generateDraft() invokes Payment.generateDraft() passing itself as a Payable. 4.) Payment.generateDraft() invokes Payable.getAmount() 44
  • 46. Implementation Factory Use factories to create a modules implementation classes. 46
  • 49. Modular Architecture Today Introducing OSGi? This is the Is OS What is OSG Gi new? Who i s usin Infrastructure & i? g OSG i? Programming Model 49
  • 50. Modularity is coming to the Java platform! OpenJDK 50
  • 51. A Bit of History • JSR 8 - Open Services Gateway specification in 1999 (JSR 232 or JSR 291) • Gateway for providing services to home devices • lifecycle management, dependencies, installing, versioning, configuration • OSGi Alliance formed in 1999 and delivered V1.0 in 2000 • Very popular on the desktop; driven by Eclipse 3.0 adoption in 2003 • Today, just about all Java middleware products use OSGi • WAS, WebLogic, GlassFish, Paremus Service Fabric, JBoss, Geronimo, ... 51
  • 52. Introducing OSGi Dynamic Module System for Java ClassLoaders - Each bundle has it’s own classloader and it’s own lifecycle µServices - Bundle exposes it’s behavior via well-defined interface MODULE Bundles - Bundle is a JAR file with manifest 52
  • 53. A Valid Bundle myjar.jar Manifest.mf Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Scala Calculator JAR + Bundle-SymbolicName: scala calculator Bundle-Version: 1.0.0 Import-Package: com.extensiblejava.loan,scala.annotation.unchecked;us es:="scala.reflect,scala" ;version="2.8.0.final" <osgi:service id="LoanCalculator" ref="loanCalculator" interface="com.extensiblejava.loan.LoanCalculator"/> Register µServices <osgi:reference id="paymentFactory" µService Reference interface="com.extensiblejava.loan.PaymentFactory"/> 53
  • 54. The Basic Workings Private packages Classloader restricts are implementation visibility Imported Exported packages packages Publishes the JAR is a module interface, ideally as Classloader gives µServices each module its own DYNAMICITY lifecycle 54
  • 55. Modules as First Class Citizens INSTALLED STARTING start Because bundles have their own classloader, they can be managed independently. RESOLVED ACTIVE Hence, a very dynamic environment. stop UNINSTALLED STOPPING 55
  • 56. demo The Runtime - Dyn ami - Mult c deployme ipl nt - Enfo e versions rce de - Enca pen de psulat ncies ion 56
  • 57. demo Too Complex? “OSGi provides little value and is too complex as demonstrated by our failed attempt to make modularity invisible when porting our legacy system to it with over 150 third-party JARs. -- http://blogs.mulesoft.org/osgi-no-thanks “OSGi is a great solution for complex applications with stringent modularity requirements.” -- http://www.theserverside.com/news/thread.tss?thread_id=62590 57
  • 58. A Modular System TODAY! 58
  • 59. Standard Java Lack Encapsulation Everything is still visible; no dynamics! 59
  • 61. Type Visibility Any public class in any JAR on the classpath can be seen by any other class on the classpath! With OSGi, you have control who sees what! Cookie Jar images courtesy of Richard Hall 61
  • 63. demo Encapsulation Nothing can reach this class! 63
  • 64. Modularity Today Platforms discourage modularity! Why a re design n’t we in mo dul g more ar sof tware ? 64
  • 65. demo Modularity Tomorrow This is the next generation application platform! - Dyn ami - Mult c deployme ipl nt - Expl e versions icit de pen de ncies 65
  • 66. Modular Architecture Today OSGi-ify the App Ho w d o I bu Is it i Is it r applic ild nvasiv eally ations e to m to o co using y co de mplex OSGi? ? ? 66
  • 67. Java Application Architecture Modularity Patterns with Examples Using OSGi Forewords by Robert C. Martin and Peter Kriens I’m dancing! By god I’m dancing on the walls. I’m dancing on the ceiling. I’m ecstatic. I’m overjoyed. I’m really, really pleased.” - From the Foreword by Robert C. Martin (a.k.a. Uncle Bob) Java Application Architecture will help you ‣Design modular software that is extensible, reusable, maintainable, and adaptable ‣Design modular software today, in anticipation of platform support for modularity ‣Break large software systems into a flexible composite of collaborating modules ‣Understand where to place your architectural focus ‣Migrate large-scale monolithic applications to applications with a modular architecture ‣Articulate the advantages of modular software to your team Visit http://modularity.kirkk.com for more information. 67
  • 68. Q&A 68