Introducing a Software
Generator Framework


Stephan Hochdörfer
bitExpert AG
ABOUT ME

> Stephan Hochdörfer, bitExpert AG


> Department Manager Research Labs


> S.Hochdoerfer@bitExpert.de


> @shochdoerfer




                                     2
GENERATING SOFTWARE




                      3
GENERATING SOFTWARE




         WTF?!?

                      4
One customer, one optimized application




                                          5
Developer   vs.   Businessman

                                6
New customer with different requirements
                                           7




                                           7
Different requirements: intensive workload




                                             8
Different requirements: Focus on performance




                                               9
Where will this lead to?

                           10
Maintanance nightmare!




                         11
Standardize you should!
                          12
Application framework?




                         13
Manually wiring everything up?

                                 14
No automation? No Tooling support?

                                     15
Generalize you should!
                         16
GENERATIVE PROGRAMMING




 Dealing with software system families,
 reusable implementation components
     and configuration knowledge.



                                          17
GENERATIVE PROGRAMMING: WORKFLOW




                 Generator
                 Generator



                                   18
GENERATIVE PROGRAMMING: WORKFLOW



                Configuration
                 Configuration
                   (DSL)
                    (DSL)




                 Generator
                 Generator



                                   19
GENERATIVE PROGRAMMING: WORKFLOW



                    Configuration
                     Configuration
                       (DSL)
                        (DSL)




 Implementation-
  Implementation-
   components
                    Generator
                    Generator
    components




                                     20
GENERATIVE PROGRAMMING: WORKFLOW



                    Configuration
                     Configuration
                       (DSL)
                        (DSL)



                                     1..n

 Implementation-
  Implementation-
   components
                    Generator
                    Generator          Product
                                        Product
    components




                                              21
GENERATIVE PROGRAMMING: WORKFLOW



                    Configuration
                     Configuration
                       (DSL)
                        (DSL)




 Implementation-
  Implementation-
   components
                    Generator
                    Generator        Customer 11
                                      Customer
    components




                                              22
GENERATIVE PROGRAMMING: WORKFLOW



                    Configuration
                     Configuration
                       (DSL)
                        (DSL)
                                     Customer 22
                                      Customer




 Implementation-
  Implementation-
   components
                    Generator
                    Generator        Customer 11
                                      Customer
    components




                                              23
Focus on the (software system) family!
                                         24




                                         24
SOFTWARE SYSTEM FAMILY




     Set of applications with similar
 properties as well as special properties
      for each individual member.



                                            25
Phase 1: Domain analysis




                           26
Listen to the customers

                          27
Talk to the domain experts




                             28
Do the requirements make sense?




                                  29
Does it belong to the family?


                                30
Does it belong to the family?


                                31
Does it belong to the family?


                                32
Does it belong to the family? Maybe...


                                         33
Does it belong to the family? No!


                                    34
Does it belong to the family? No!


                                    35
Phase 2: Domain design




                         36
Feature Modelling
                    37
Phase 3: Domain implementation




                                 38
Implementation components
                            39
Configuration Knowledge
                          40
GENERATIVE PROGRAMMING


       Generator
    Domain Engineering


         Domain-
         analysis


         Domain-
          design


         Domain-
      implementation

                         41
GENERATIVE PROGRAMMING


       Generator                             Product
    Domain Engineering                    App. Engineering
                         New
                         requirements

         Domain-                           Requirements
         analysis                            analysis


         Domain-                             Product
          design                           configuration


                         Components,
         Domain-         DSL,               Testing and
      implementation     Generators,
                         Infrastructure
                                            integration

                                                             42
Technology projection
                        43
GENERATIVE PROGRAMMING: FRAMEWORK




           http://replicatorframework.org




                                            44
GENERATIVE PROGRAMMING: FRAMEWORK




    Java + Maven + Spring + Eclipse




                                      45
GENERATIVE PROGRAMMING: FRAMEWORK




                mvn archetype:create
     -DarchetypeGroupId=org.replicatorframework
   -DarchetypeArtifactId=replicator-maven-archetype
        -DarchetypeVersion=0.8.0-SNAPSHOT
          -DgroupId=org.replicatorframework
             -DartifactId=samplegenerator




                                                      46
GENERATIVE PROGRAMMING: FRAMEWORK

         ./samplegenerator
            |-config
            |---generator.properties
            |---gpl.xml
            |-src
            |---main
            |-----java
            |-----resources
            |-------frames
            |-------generator
            |---------contentProvider.xml
            |---------features.xml
            |---------frames.xml
            |---------generatorContext.xml
            |---test
            |-----java
            |-----resources
            |-target
                                             47
GENERATIVE PROGRAMMING: ADD FEATURE
./src/main/resources/generator/features.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:gp="http://www.replicatorframework.org/schema/gp"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.springframework.org/...">

    <gp:feature name="ContactForm" />

   <gp:feature name="HintLayer" />
</beans>




                                                         48
GENERATIVE PROGRAMMING: ADD FRAME
./src/main/resources/generator/frames.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:gp="http://www.replicatorframework.org/schema/gp"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.springframework.org/...">

    <gp:fileframe id="App.ContactForm"
        sourcePath="frames/webroot/form.frm"
        exportPath="webroot/form.html">
    </gp:fileframe>

    <gp:frame id="App.ContactForm.HintLayer"
        sourcePath="frames/webroot/hintlayer.frm">
    </gp:frame>

   <gp:bundle id="App.Resources.Images"
       sourcePath="frames/webroot/resources/img"
       exportPath="webroot/resources/img" />             49
</beans>
GENERATIVE PROGRAMMING: ADD FRAME
./src/main/resources/generator/features.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:gp="http://www.replicatorframework.org/schema/gp"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.springframework.org/...">

    <gp:feature name="ContactForm">
      <!-- refers to the defined FileFrame -->
      <gp:resource ref="App.ContactForm"/>
      <!-- refers to the defined ResourceBundle -->
      <gp:resource ref="App.Resources.Images"/>
    </gp:feature>

   <gp:feature name="HintLayer" />
</beans>


                                                         50
GENERATIVE PROGRAMMING




       What about custom logic?




                                  51
GENERATIVE PROGRAMMING: CONTENT
PROVIDER
./src/main/resources/frames/webroot/form.frm
<html>
<head>
  <title>Sample form</title>
</head>
<body>
<h1><!{hello}!></h1>
<form action="index.do" method="post">
<textarea name="msg"></textarea>
</form>
<!{hint}!>
</body>
</html>




                                               52
GENERATIVE PROGRAMMING: CONTENT
PROVIDER
./src/main/resources/generator/contentProvider.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:gp="http://www.replicatorframework.org/schema/gp"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.springframework.org/...">

   <gp:contentProvider id="GenericContentProvider"
      type="generic">
      <gp:rule>
          <gp:condition>
            <gp:group type="AND">
               <gp:hasFeature name="ContactForm"/>
            </gp:group>
          </gp:condition>
         <gp:bind slot="hello" value="Hello World!"></gp:bind>
      </gp:rule>
   </gp:contentProvider>
</beans>                                                   53
GENERATIVE PROGRAMMING: CONTENT
PROVIDER
./src/main/resources/generator/contentProvider.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:gp="http://www.replicatorframework.org/schema/gp"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.springframework.org/...">

   <gp:contentProvider id="GenericContentProvider"
       type="generic">
       <gp:rule>
           <gp:condition>
               <gp:hasFeature name="HintLayer"/>
           </gp:condition>
           <gp:bind slot="hint"
               ref="App.ContactForm.HintLayer" />
       </gp:rule>
   </gp:contentProvider>
</beans>
                                                         54
GENERATIVE PROGRAMMING




           Code anyone?




                          55
GENERATIVE PROGRAMMING: CONTENT
PROVIDER
./src/java/org/replicatorframework/samplegenerator/MyContentProvider.java
package org.replicatorframework.samplegenerator;
import
org.replicatorframework.generator.frame.contentprovid...
import org.replicatorframework.gpl.FeatureConfiguration;

public class MyContentProvider extends AbstractContentProvider
{
    public SlotConfiguration computeSlots(FeatureConfiguration
       configuration)
    {
       SlotConfiguration slots = new SlotConfiguration();
       slots.put("hello", "Hello World!");
       slots.put("hint",
          this.getFrameDefinition("App.ContactForm.HintLayer")
       );

        return slots;
    }                                                               56
}
GENERATIVE PROGRAMMING: CONFIGURATION
./config/gpl.xml
<?xml version="1.0" encoding="UTF-8"?>
<features xmlns="http://www.replicatorframework.org/schema/gpl"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.replicatorframework.org/...
   http://www.replicatorframework.org/schema/gpl/gpl-
0.0.6.xsd">

   <feature name="hintLayer">
       <param name="color" type="String" value="#000" />
       <param name="autoClose" type="Boolean" value="true" />
   </feature>
</features>




                                                          57
GENERATIVE PROGRAMMING




      How to run the generator?




                                  58
GENERATIVE PROGRAMMING




          mvn replicator:run




                               59
GENERATIVE PROGRAMMING: THE GOAL




      Increasing the productivity,
      quality, and time-to-market




                                     60
GENERATIVE PROGRAMMING: THE GOAL




         Creating an optimized
        application on demand!




                                   61
GENERATIVE PROGRAMMING: BONUS POINTS




                                       62
GENERATIVE PROGRAMMING: BONUS POINTS




        Less error-prone, due to
              automation




                                       63
GENERATIVE PROGRAMMING: BONUS POINTS




     Reduce the complexity of the
             application




                                       64
GENERATIVE PROGRAMMING: BONUS POINTS




       Just one code repository:
        The software generator




                                       65
GENERATIVE PROGRAMMING: BONUS POINTS




      Reduce maintenance efforts




                                       66
GENERATIVE PROGRAMMING: THE BOOK




                                   67
Stephan Hochdörfer   http://www.bitExpert.de
bitExpert AG         S.Hochdoerfer@bitExpert.de

Introducing a Software Generator Framework - JAZOON12

  • 1.
    Introducing a Software GeneratorFramework Stephan Hochdörfer bitExpert AG
  • 2.
    ABOUT ME > StephanHochdörfer, bitExpert AG > Department Manager Research Labs > [email protected] > @shochdoerfer 2
  • 3.
  • 4.
  • 5.
    One customer, oneoptimized application 5
  • 6.
    Developer vs. Businessman 6
  • 7.
    New customer withdifferent requirements 7 7
  • 8.
  • 9.
  • 10.
    Where will thislead to? 10
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
    No automation? NoTooling support? 15
  • 16.
  • 17.
    GENERATIVE PROGRAMMING Dealingwith software system families, reusable implementation components and configuration knowledge. 17
  • 18.
    GENERATIVE PROGRAMMING: WORKFLOW Generator Generator 18
  • 19.
    GENERATIVE PROGRAMMING: WORKFLOW Configuration Configuration (DSL) (DSL) Generator Generator 19
  • 20.
    GENERATIVE PROGRAMMING: WORKFLOW Configuration Configuration (DSL) (DSL) Implementation- Implementation- components Generator Generator components 20
  • 21.
    GENERATIVE PROGRAMMING: WORKFLOW Configuration Configuration (DSL) (DSL) 1..n Implementation- Implementation- components Generator Generator Product Product components 21
  • 22.
    GENERATIVE PROGRAMMING: WORKFLOW Configuration Configuration (DSL) (DSL) Implementation- Implementation- components Generator Generator Customer 11 Customer components 22
  • 23.
    GENERATIVE PROGRAMMING: WORKFLOW Configuration Configuration (DSL) (DSL) Customer 22 Customer Implementation- Implementation- components Generator Generator Customer 11 Customer components 23
  • 24.
    Focus on the(software system) family! 24 24
  • 25.
    SOFTWARE SYSTEM FAMILY Set of applications with similar properties as well as special properties for each individual member. 25
  • 26.
    Phase 1: Domainanalysis 26
  • 27.
    Listen to thecustomers 27
  • 28.
    Talk to thedomain experts 28
  • 29.
    Do the requirementsmake sense? 29
  • 30.
    Does it belongto the family? 30
  • 31.
    Does it belongto the family? 31
  • 32.
    Does it belongto the family? 32
  • 33.
    Does it belongto the family? Maybe... 33
  • 34.
    Does it belongto the family? No! 34
  • 35.
    Does it belongto the family? No! 35
  • 36.
    Phase 2: Domaindesign 36
  • 37.
  • 38.
    Phase 3: Domainimplementation 38
  • 39.
  • 40.
  • 41.
    GENERATIVE PROGRAMMING Generator Domain Engineering Domain- analysis Domain- design Domain- implementation 41
  • 42.
    GENERATIVE PROGRAMMING Generator Product Domain Engineering App. Engineering New requirements Domain- Requirements analysis analysis Domain- Product design configuration Components, Domain- DSL, Testing and implementation Generators, Infrastructure integration 42
  • 43.
  • 44.
    GENERATIVE PROGRAMMING: FRAMEWORK http://replicatorframework.org 44
  • 45.
    GENERATIVE PROGRAMMING: FRAMEWORK Java + Maven + Spring + Eclipse 45
  • 46.
    GENERATIVE PROGRAMMING: FRAMEWORK mvn archetype:create -DarchetypeGroupId=org.replicatorframework -DarchetypeArtifactId=replicator-maven-archetype -DarchetypeVersion=0.8.0-SNAPSHOT -DgroupId=org.replicatorframework -DartifactId=samplegenerator 46
  • 47.
    GENERATIVE PROGRAMMING: FRAMEWORK ./samplegenerator |-config |---generator.properties |---gpl.xml |-src |---main |-----java |-----resources |-------frames |-------generator |---------contentProvider.xml |---------features.xml |---------frames.xml |---------generatorContext.xml |---test |-----java |-----resources |-target 47
  • 48.
    GENERATIVE PROGRAMMING: ADDFEATURE ./src/main/resources/generator/features.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:gp="http://www.replicatorframework.org/schema/gp" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/..."> <gp:feature name="ContactForm" /> <gp:feature name="HintLayer" /> </beans> 48
  • 49.
    GENERATIVE PROGRAMMING: ADDFRAME ./src/main/resources/generator/frames.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:gp="http://www.replicatorframework.org/schema/gp" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/..."> <gp:fileframe id="App.ContactForm" sourcePath="frames/webroot/form.frm" exportPath="webroot/form.html"> </gp:fileframe> <gp:frame id="App.ContactForm.HintLayer" sourcePath="frames/webroot/hintlayer.frm"> </gp:frame> <gp:bundle id="App.Resources.Images" sourcePath="frames/webroot/resources/img" exportPath="webroot/resources/img" /> 49 </beans>
  • 50.
    GENERATIVE PROGRAMMING: ADDFRAME ./src/main/resources/generator/features.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:gp="http://www.replicatorframework.org/schema/gp" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/..."> <gp:feature name="ContactForm"> <!-- refers to the defined FileFrame --> <gp:resource ref="App.ContactForm"/> <!-- refers to the defined ResourceBundle --> <gp:resource ref="App.Resources.Images"/> </gp:feature> <gp:feature name="HintLayer" /> </beans> 50
  • 51.
    GENERATIVE PROGRAMMING What about custom logic? 51
  • 52.
    GENERATIVE PROGRAMMING: CONTENT PROVIDER ./src/main/resources/frames/webroot/form.frm <html> <head> <title>Sample form</title> </head> <body> <h1><!{hello}!></h1> <form action="index.do" method="post"> <textarea name="msg"></textarea> </form> <!{hint}!> </body> </html> 52
  • 53.
    GENERATIVE PROGRAMMING: CONTENT PROVIDER ./src/main/resources/generator/contentProvider.xml <?xmlversion="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:gp="http://www.replicatorframework.org/schema/gp" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/..."> <gp:contentProvider id="GenericContentProvider" type="generic"> <gp:rule> <gp:condition> <gp:group type="AND"> <gp:hasFeature name="ContactForm"/> </gp:group> </gp:condition> <gp:bind slot="hello" value="Hello World!"></gp:bind> </gp:rule> </gp:contentProvider> </beans> 53
  • 54.
    GENERATIVE PROGRAMMING: CONTENT PROVIDER ./src/main/resources/generator/contentProvider.xml <?xmlversion="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:gp="http://www.replicatorframework.org/schema/gp" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/..."> <gp:contentProvider id="GenericContentProvider" type="generic"> <gp:rule> <gp:condition> <gp:hasFeature name="HintLayer"/> </gp:condition> <gp:bind slot="hint" ref="App.ContactForm.HintLayer" /> </gp:rule> </gp:contentProvider> </beans> 54
  • 55.
    GENERATIVE PROGRAMMING Code anyone? 55
  • 56.
    GENERATIVE PROGRAMMING: CONTENT PROVIDER ./src/java/org/replicatorframework/samplegenerator/MyContentProvider.java packageorg.replicatorframework.samplegenerator; import org.replicatorframework.generator.frame.contentprovid... import org.replicatorframework.gpl.FeatureConfiguration; public class MyContentProvider extends AbstractContentProvider { public SlotConfiguration computeSlots(FeatureConfiguration configuration) { SlotConfiguration slots = new SlotConfiguration(); slots.put("hello", "Hello World!"); slots.put("hint", this.getFrameDefinition("App.ContactForm.HintLayer") ); return slots; } 56 }
  • 57.
    GENERATIVE PROGRAMMING: CONFIGURATION ./config/gpl.xml <?xmlversion="1.0" encoding="UTF-8"?> <features xmlns="http://www.replicatorframework.org/schema/gpl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.replicatorframework.org/... http://www.replicatorframework.org/schema/gpl/gpl- 0.0.6.xsd"> <feature name="hintLayer"> <param name="color" type="String" value="#000" /> <param name="autoClose" type="Boolean" value="true" /> </feature> </features> 57
  • 58.
    GENERATIVE PROGRAMMING How to run the generator? 58
  • 59.
    GENERATIVE PROGRAMMING mvn replicator:run 59
  • 60.
    GENERATIVE PROGRAMMING: THEGOAL Increasing the productivity, quality, and time-to-market 60
  • 61.
    GENERATIVE PROGRAMMING: THEGOAL Creating an optimized application on demand! 61
  • 62.
  • 63.
    GENERATIVE PROGRAMMING: BONUSPOINTS Less error-prone, due to automation 63
  • 64.
    GENERATIVE PROGRAMMING: BONUSPOINTS Reduce the complexity of the application 64
  • 65.
    GENERATIVE PROGRAMMING: BONUSPOINTS Just one code repository: The software generator 65
  • 66.
    GENERATIVE PROGRAMMING: BONUSPOINTS Reduce maintenance efforts 66
  • 67.
  • 68.
    Stephan Hochdörfer http://www.bitExpert.de bitExpert AG [email protected]