Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Developing Modular Web Applications

Developing Modular Web Applications

Developing Modular Web Applications using the Fenix Framework

João Carvalho

April 11, 2014
Tweet

More Decks by João Carvalho

Other Decks in Programming

Transcript

  1. Developing modular
    (Web) Applications
    Using the Fenix Framework
    Luis Cruz & João Carvalho
    April 2014

    View Slide

  2. Outline
    • FenixEdu
    • What does modular mean?
    • Benefits
    • Challenges

    View Slide

  3. View Slide

  4. View Slide

  5. View Slide

  6. 12 Years Ago

    View Slide


  7. Presentation Tier — Based on Struts
    Application Tier
    POJO’s
    Persistence Tier — Based on OJB
    XML Configuration
    Service Manager
    Services
    Filters
    XML!
    Configuration
    DTO’s
    XML!
    Configuration
    Data Repository
    JDBC
    JSP!
    Views
    Actions
    SQL Statements

    View Slide

  8. The 11 "simple" steps
    1. Create a POJO to represent the domain object;
    2. Write the SQL schema to store the domain object;
    3. Write the xml configuration to map the POJO against the SQL
    schema;
    4. Write SQL statements for custom reading of the domain object
    (in case something other than a read by ID or a read all was
    necessary);
    5. Create data transfer objects for passing information to the
    presentation tier;
    6. Write services at the application level for creating, reading,
    updating and deleting the domain object;
    7. Write access control filters to limit who can invoke services;
    8. Write service and filter configurations in a xml file;
    9. Create JSP views for presenting information to the users;
    10. Write Actions to handle user requests;
    11. Configure struts xml files to specify the application flow.

    View Slide

  9. Fenix Framework

    View Slide


  10. Presentation Tier — Based on Struts
    Application Tier
    Persistence Tier — Fenix Framework Based
    Service Manager
    Services
    Filters
    XML!
    Configuration
    Domain!
    Objects
    XML!
    Configuration
    Data Repository
    JDBC
    JSP!
    Views
    Actions
    DML Configuration

    View Slide

  11. This allowed the
    application to grow

    View Slide

  12. User
    Person

    View Slide

  13. Domain Model Complexity

    View Slide

  14. Quickly grew out of
    control

    View Slide

  15. • Long compilation times
    • Large memory requirements
    • Poor expansibility
    • Poor encapsulation
    • It becomes easy to break domain constraints

    View Slide

  16. Solution?

    View Slide

  17. Modularisation

    View Slide

  18. What is modularisation?

    View Slide

  19. Divide and conquer

    View Slide

  20. Breaking your application
    into smaller parts

    View Slide

  21. Clear boundary
    definition

    View Slide

  22. Build your application
    from the small modules

    View Slide

  23. Persistence Tier — Fenix Framework Based
    Data Repository
    Fenix Application
    Request Controller
    Module 1
    Presentation Tier
    Application Tier
    Domain
    Objects
    Module 2
    Presentation Tier
    Application Tier
    Domain
    Objects
    ...
    Module N
    Presentation Tier
    Application Tier
    Domain
    Objects

    View Slide

  24. Benefits

    View Slide

  25. Separation of
    Concerns

    View Slide

  26. Greater Cohesion

    View Slide

  27. Abstraction

    View Slide

  28. Encapsulation

    View Slide

  29. Independent roadmaps

    View Slide

  30. Improved
    development process

    View Slide

  31. Reusability

    View Slide

  32. Pluggability

    View Slide

  33. DOT!
    IST
    DOT !
    IST-ID
    FENIX !
    IST
    DOT !
    ADIST
    DOT !
    Reitoria!
    UL
    SOTIS
    JobBank
    SIADAP!
    Processes
    SnailMail!
    Tracking
    Domain!
    Browser
    Renderers
    Organizationa
    l!
    Module
    Fenix!
    Framework
    Regulation!
    Dispatch
    Financial!
    Projects
    Workflow
    File!
    Manage-ment
    Working!
    Capital
    Expenditure
    s
    Messaging
    Inst.!
    Protocols
    Bennu !
    Framework
    WebServic
    e
    Scaffolding
    Authentica-
    tion
    i18n
    Groups &
    ACLs
    WebApp
    Scaffolding
    Scheduler
    Persistent
    IO
    Indexing
    Support

    View Slide

  34. Challenges

    View Slide

  35. Thinking in modules
    (Or thinking inside the box)

    View Slide

  36. Choosing your build
    tool

    View Slide

  37. Versioning

    View Slide

  38. Versioning
    • What’s the difference between:
    • v1.1.3 and v1.1.4?
    • v1.2.3 and v1.3.5?
    • v1.3.5 and v2.0.0?

    View Slide

  39. Semantic Versioning
    • Major Version (2.0.0)
    • API Disruption
    • Minor Version (1.2.0)
    • New (backward-compatible) API
    • Revision (1.2.3)
    • Bug fixes and internal changes
    http://semver.org/

    View Slide

  40. You must explicitly declare
    your dependencies
    (and their versions)

    View Slide

  41. A @
    1.0.0
    B @
    2.3.1

    View Slide

  42. Dependency Nightmare
    org.fenixedu:bennu-portal:jar:2.3.0-SNAPSHOT
    +- org.fenixedu:bennu-core:jar:2.3.0-SNAPSHOT:compile
    | +- org.jasig.cas.client:cas-client-core:jar:3.3.0:compile
    | \- org.antlr:antlr-runtime:jar:3.5.2:compile
    +- org.fenixedu:fenixedu-commons:jar:1.0.0:compile
    +- com.google.guava:guava:jar:15.0:compile
    +- joda-time:joda-time:jar:2.3:compile
    +- com.google.code.gson:gson:jar:2.2.4:compile
    +- javax.ws.rs:javax.ws.rs-api:jar:2.0:compile
    +- com.mitchellbosecke:pebble:jar:1.0.0:compile
    | \- com.coverity.security:coverity-escapers:jar:1.1:compile
    +- pt.ist:fenix-framework-core-api:jar:2.4.0:compile
    | +- pt.ist:fenix-framework-core-dml:jar:2.4.0:compile
    | | +- commons-lang:commons-lang:jar:2.6:compile
    | | \- antlr:antlr:jar:2.7.7:compile
    | +- javax.transaction:jta:jar:1.1:compile
    | +- pt.ist.esw:advice-runtime:jar:1.8:compile
    | \- org.jgroups:jgroups:jar:3.2.7.Final:compile
    +- pt.ist:fenix-framework-core-consistency-predicates:jar:2.4.0:compile
    | +- jvstm:jvstm-fenix:jar:1.4:compile
    | \- pt.ist:fenix-framework-core-adt-bplustree:jar:2.4.0:compile
    +- javax.servlet:javax.servlet-api:jar:3.0.1:provided
    +- org.slf4j:slf4j-api:jar:1.7.5:compile
    \- junit:junit:jar:4.11:test
    \- org.hamcrest:hamcrest-core:jar:1.3:test

    View Slide

  43. Managing dependencies
    can be chaotic!

    View Slide

  44. Inconsistencies
    A @
    1.0.0
    C @
    2.3.1
    B @
    2.3.5
    C @
    3.4.0
    YourApp @
    1.0.0
    Conflict!

    View Slide

  45. Circular Dependencies
    A @
    1.0.0
    C @
    2.3.1
    B @
    2.3.5

    View Slide

  46. Managing Graph
    Complexity

    View Slide

  47. Source Management

    View Slide

  48. One branch per
    feature

    View Slide

  49. Tagging every release

    View Slide

  50. Distributed tools help
    a lot…

    View Slide

  51. Artifact Management

    View Slide

  52. Building everything from
    source can be painful
    (I’m looking at you Gentoo)

    View Slide

  53. Where to keep
    compiled artifacts?

    View Slide

  54. Artifact Repository

    View Slide

  55. Modular
    Infrastructure

    View Slide

  56. Many frameworks are
    not modular-friendly…

    View Slide

  57. … and the language
    doesn’t help.
    Java 9, prove me wrong!

    View Slide

  58. Fenix Framework

    View Slide

  59. Fenix Framework 1.x
    FenixFramework.initialize(new Config() {
    {
    dbAlias = "//localhost:3306/hellodb";
    dbUsername = "hello";
    dbPassword = "world";
    domainModelPath = "src/main/dml/domain.dml";
    rootClass = MyRootClass.class;
    }
    });

    View Slide

  60. Single Domain Model!

    View Slide

  61. No bidirectional
    relations

    View Slide

  62. No encapsulation

    View Slide

  63. How to allow modules to
    define their own DMLs?

    View Slide

  64. Fenix Framework 2.0

    View Slide

  65. Make modularity a
    core concern

    View Slide

  66. Creates the complete
    domain from the
    dependency graph

    View Slide

  67. Bidirectional
    Dependencies

    View Slide

  68. Each module can only
    see its sub-graph
    Which is different for every module

    View Slide

  69. Fenix Framework 2.0
    dbAlias=//localhost:3306/fenix1
    dbUsername=root
    dbPassword=
    fenix-framework.properties

    View Slide

  70. Presentation

    View Slide

  71. • Structure and styling
    • Menus and navigation
    • Multiple presentation technologies

    View Slide

  72. Bennu Portal

    View Slide

  73. It’s magic!

    View Slide

  74. Integration framework

    View Slide

  75. Uniform styling across
    the entire application

    View Slide

  76. Dynamic menu
    construction/rendering

    View Slide

  77. Functionalities only
    render their body

    View Slide

  78. Out of the box scaffolding
    for web applications

    View Slide

  79. Build your own
    application in 2 minutes

    View Slide

  80. Q?

    View Slide

  81. Join Us
    http://fenixedu.org/dev
    github.com/fenixedu!
    facebook.com/fenixedu
    [email protected]

    View Slide

  82. Developing modular
    (Web) Applications
    Using the Fenix Framework
    Luis Cruz & João Carvalho
    April 2014

    View Slide