Agile RCP Presenter First using Spring Dynamic Modules Heiko Seeberger | metafinanz
Concepts 1 2 3 Application to RCP Agile RCP framework
What is agile? Develop exactly what is required. Test-driven development. …
How can we be agile? We need: Agile process driving the design. Architecture allowing for unit-testing. …
Can UI development be agile? “ User interfaces are hard to unit-test” : Tangling of presentation and logic. Dependency on concrete UI technologies.
Example: Unit-testing UIs UI logic  Verify input Invoke addition
Test Cases How to implement these Test Cases? Non-digits => Log error  “Illegal format …” . 123 + 999 => 1122. Example
Vanilla approach Put “everything” into one Composite: Text, label and button controls. Handling button clicks: Verify input, possibly display error. Invoke “business logic”. Show result. Example
Vanilla tastes, but … Quick win for the implementation. Disastrous for testing. Why? Let me show you (demo) … Example
Any better ideas?
Use Model-View-Presenter Similar to MVC, but: Controllers for widgets, presenters for views. Widgets hand off user gestures to presenter. View Presenter Model
Passive View Does not listen to model updates. All UI logic in presenter. passive UI logic View Presenter Model Testing UI logic == Presenter testing
Interface abstractions Interfaces for model and view. Mock model and view to test presenters. passive UI logic IView Presenter IModel PresenterTest MockView MockModel Presenter testing == Easy Testing UI logic == Easy
Presenter First architecture MVP. Passive View. Interface abstractions for model and view. passive UI logic IView Presenter IModel
Presenter First process IView Presenter IModel The user can  query  for  books  by entering the  title  in the query form … User Story -onQuery() … +getName() … +getBooks() … Requirements drive the design.
Presenter First (PF) answers: How can we be agile? Can UI development be agile? Delivers an  agile process  driving the design. Based on an Architecture  enabling unit-testing . Untangles  presentation and logic. Abstracts  from concrete UI technologies.
Presenter First approach IView Presenter IModel The user can enter two addends. Clicking “=“ will add and show their sum. User Story -handleAdd() … +getAddend01() +getAddend02() +setSum() +add() … Example +getAddend01() +getAddend02() +setSum() +registerAddHandler()
Presenter First approach Example Demo …
Test the presenter Example
Full test coverage for UI logic Example
Concepts 1 2 3 Application to RCP Agile RCP framework
How to create the MVP triads? IView Presenter IModel MockView MockModel View Model
Use Spring! Application context Presenter View Model
Spring Dynamic Modules Integration of OSGi/RCP and Spring: Active bundle    Spring application context. Bundle Application context Bean Bean Bean
Example Application context ContactsPresenter ContactsView Contacts Model
Sharing beans across bundles Exporting  beans as OSGi services. Importing  OSGi services as bean references. Bundle Application context Bundle Application context Bean Bean Bean Bean Bean
Im-/exporting services Importing an OSGi service: Exporting a bean as OSGi service: < service  ref = &quot;personRepository&quot;  auto-export = &quot;interfaces&quot; > </service> < reference  id = &quot;personRepository&quot; interface = &quot;org.agilercp.demo.contacts.IPersonRepository&quot; > </ reference >
Example org.agilercp.demo.contacts.ui Application context ContactsModel org.agilercp.demo.contacts Application context PersonRepository
How to create ViewParts? ViewParts are created by the workbench. How can we use the Spring created ones? Workbench views xPt ViewPart
The workbench is flexible! Workbench ViewPartFactory views xPt IExecutable- ExtensionFactory IExecutable- Extension getBean viewId (viewId) Application context Presenter View Model
Example
How to create Dialogs? Let Spring create the Dialog. Inject it into opening MVP triad. Application context Dialog ViewPart Presenter View Model Presenter View Model dialog
Example
Concepts 1 2 3 Application to RCP Agile RCP framework
Agile RCP Presenter First framework for RCP. Emerged from a real-world project. Open Source:  http:// sourceforge.net/projects/agilercp . Website:  http:// agilercp.metafinanz.de .
Challenge Spring instantiates views, but controls created later. How can a presenter initialize its view  before it is shown?
Agile RCP supports MVP life cycle
Showing views … M and V are instantiated. P is instantiated and M and V are injected. P initializes V. P registers itself as IViewListener to V. V is created. V is shown.
Agile RCP delivers a view factory Has access to Spring application context. Gets workbench parts by view/editor id.
Agile RCP delivers a lot more Base classes for ViewParts. Base classes for Dialogs. Utility classes. … And a lot more is planned!
Agile RCP approach Example Demo: New requirement: Initialize view with “123 + 999 = 1122”
Thank you! Website:  http:// agilercp.metafinanz.de Agile RCP at sourceforge.net:  http://sourceforge.net/projects/agilercp Contact me:  [email_address]

JAX 08 - Agile RCP

  • 1.
    Agile RCP PresenterFirst using Spring Dynamic Modules Heiko Seeberger | metafinanz
  • 2.
    Concepts 1 23 Application to RCP Agile RCP framework
  • 3.
    What is agile?Develop exactly what is required. Test-driven development. …
  • 4.
    How can webe agile? We need: Agile process driving the design. Architecture allowing for unit-testing. …
  • 5.
    Can UI developmentbe agile? “ User interfaces are hard to unit-test” : Tangling of presentation and logic. Dependency on concrete UI technologies.
  • 6.
    Example: Unit-testing UIsUI logic Verify input Invoke addition
  • 7.
    Test Cases Howto implement these Test Cases? Non-digits => Log error “Illegal format …” . 123 + 999 => 1122. Example
  • 8.
    Vanilla approach Put“everything” into one Composite: Text, label and button controls. Handling button clicks: Verify input, possibly display error. Invoke “business logic”. Show result. Example
  • 9.
    Vanilla tastes, but… Quick win for the implementation. Disastrous for testing. Why? Let me show you (demo) … Example
  • 10.
  • 11.
    Use Model-View-Presenter Similarto MVC, but: Controllers for widgets, presenters for views. Widgets hand off user gestures to presenter. View Presenter Model
  • 12.
    Passive View Doesnot listen to model updates. All UI logic in presenter. passive UI logic View Presenter Model Testing UI logic == Presenter testing
  • 13.
    Interface abstractions Interfacesfor model and view. Mock model and view to test presenters. passive UI logic IView Presenter IModel PresenterTest MockView MockModel Presenter testing == Easy Testing UI logic == Easy
  • 14.
    Presenter First architectureMVP. Passive View. Interface abstractions for model and view. passive UI logic IView Presenter IModel
  • 15.
    Presenter First processIView Presenter IModel The user can query for books by entering the title in the query form … User Story -onQuery() … +getName() … +getBooks() … Requirements drive the design.
  • 16.
    Presenter First (PF)answers: How can we be agile? Can UI development be agile? Delivers an agile process driving the design. Based on an Architecture enabling unit-testing . Untangles presentation and logic. Abstracts from concrete UI technologies.
  • 17.
    Presenter First approachIView Presenter IModel The user can enter two addends. Clicking “=“ will add and show their sum. User Story -handleAdd() … +getAddend01() +getAddend02() +setSum() +add() … Example +getAddend01() +getAddend02() +setSum() +registerAddHandler()
  • 18.
    Presenter First approachExample Demo …
  • 19.
  • 20.
    Full test coveragefor UI logic Example
  • 21.
    Concepts 1 23 Application to RCP Agile RCP framework
  • 22.
    How to createthe MVP triads? IView Presenter IModel MockView MockModel View Model
  • 23.
    Use Spring! Applicationcontext Presenter View Model
  • 24.
    Spring Dynamic ModulesIntegration of OSGi/RCP and Spring: Active bundle  Spring application context. Bundle Application context Bean Bean Bean
  • 25.
    Example Application contextContactsPresenter ContactsView Contacts Model
  • 26.
    Sharing beans acrossbundles Exporting beans as OSGi services. Importing OSGi services as bean references. Bundle Application context Bundle Application context Bean Bean Bean Bean Bean
  • 27.
    Im-/exporting services Importingan OSGi service: Exporting a bean as OSGi service: < service ref = &quot;personRepository&quot; auto-export = &quot;interfaces&quot; > </service> < reference id = &quot;personRepository&quot; interface = &quot;org.agilercp.demo.contacts.IPersonRepository&quot; > </ reference >
  • 28.
    Example org.agilercp.demo.contacts.ui Applicationcontext ContactsModel org.agilercp.demo.contacts Application context PersonRepository
  • 29.
    How to createViewParts? ViewParts are created by the workbench. How can we use the Spring created ones? Workbench views xPt ViewPart
  • 30.
    The workbench isflexible! Workbench ViewPartFactory views xPt IExecutable- ExtensionFactory IExecutable- Extension getBean viewId (viewId) Application context Presenter View Model
  • 31.
  • 32.
    How to createDialogs? Let Spring create the Dialog. Inject it into opening MVP triad. Application context Dialog ViewPart Presenter View Model Presenter View Model dialog
  • 33.
  • 34.
    Concepts 1 23 Application to RCP Agile RCP framework
  • 35.
    Agile RCP PresenterFirst framework for RCP. Emerged from a real-world project. Open Source: http:// sourceforge.net/projects/agilercp . Website: http:// agilercp.metafinanz.de .
  • 36.
    Challenge Spring instantiatesviews, but controls created later. How can a presenter initialize its view before it is shown?
  • 37.
    Agile RCP supportsMVP life cycle
  • 38.
    Showing views …M and V are instantiated. P is instantiated and M and V are injected. P initializes V. P registers itself as IViewListener to V. V is created. V is shown.
  • 39.
    Agile RCP deliversa view factory Has access to Spring application context. Gets workbench parts by view/editor id.
  • 40.
    Agile RCP deliversa lot more Base classes for ViewParts. Base classes for Dialogs. Utility classes. … And a lot more is planned!
  • 41.
    Agile RCP approachExample Demo: New requirement: Initialize view with “123 + 999 = 1122”
  • 42.
    Thank you! Website: http:// agilercp.metafinanz.de Agile RCP at sourceforge.net: http://sourceforge.net/projects/agilercp Contact me: [email_address]