why spaghetti is not tasty architecting full scale swing
play

Why Spaghetti Is Not Tasty: Architecting Full-Scale Swing Apps - PowerPoint PPT Presentation

Why Spaghetti Is Not Tasty: Architecting Full-Scale Swing Apps Jasper Potts SwingTeam Sun Microsystems Inc http://jasperpotts.com TS-3316 2007 JavaOne SM Conference | Session TS-3316 | The Goals What you will take away from this session


  1. Why Spaghetti Is Not Tasty: Architecting Full-Scale Swing Apps Jasper Potts SwingTeam Sun Microsystems Inc http://jasperpotts.com TS-3316 2007 JavaOne SM Conference | Session TS-3316 |

  2. The Goals What you will take away from this session A understanding of some of the key issues of building large desktop Java™ applications. Why you need to think about these problems early on and some ways to tackle them. 2 2007 JavaOne SM Conference | Session TS-3316 |

  3. My Background • Working on Swing Team at Sun • Nimbus Look and Feel • Synth • Metal & Ocean • JTable • Creator of Xerto Imagery • Worked on large Swing Applications for: Banking, GIS and Image Processing 3 2007 JavaOne SM Conference | Session TS-3316 |

  4. The Start • How did I end up standing here talking to you today? 4 2007 JavaOne SM Conference | Session TS-3316 |

  5. Agenda  Basics  Modularity  Wiring  Communication  Conclusion  Q & A 5 2007 JavaOne SM Conference | Session TS-3316 |

  6. Setting the Scene • So you have a idea of what to build • Time to make a prototype 6 2007 JavaOne SM Conference | Session TS-3316 |

  7. Setting the Scene • Lets look at some common architectures 7 2007 JavaOne SM Conference | Session TS-3316 |

  8. Passing Everything Around MainPanel Editor Frame Quit Action Paste Action Save Action Copy Action 8 2007 JavaOne SM Conference | Session TS-3316 |

  9. Static or Singleton Core MainPanel Editor Frame Application Core Quit Action Paste Action Save Action Copy Action 9 2007 JavaOne SM Conference | Session TS-3316 |

  10. Static or Singleton Core Application Core 10 2007 JavaOne SM Conference | Session TS-3316 |

  11. Pass the Core Around MainPanel Editor Frame Application Core Quit Action Paste Action Save Action Copy Action 11 2007 JavaOne SM Conference | Session TS-3316 |

  12. Pass the Core Around Big Application MainPanel MainPanel Editor Frame Editor Frame Application Application Core Core Paste Action Quit Action Paste Action Quit Action Save Action Copy Action Save Action Copy Action 12 2007 JavaOne SM Conference | Session TS-3316 |

  13. Applications Sizes How to draw the lines • When is a application small, medium, large? • Let’s look at some example applications 13 2007 JavaOne SM Conference | Session TS-3316 |

  14. Application Sizes: Old UK Maps 14 2007 JavaOne SM Conference | Session TS-3316 |

  15. Application Sizes: Aerith 15 2007 JavaOne SM Conference | Session TS-3316 |

  16. Application Sizes: JEdit 16 2007 JavaOne SM Conference | Session TS-3316 |

  17. Application Sizes: JAlbum 17 2007 JavaOne SM Conference | Session TS-3316 |

  18. Application Sizes: Xerto Imagery 18 2007 JavaOne SM Conference | Session TS-3316 |

  19. Application Sizes: NetBeans™ Software 19 2007 JavaOne SM Conference | Session TS-3316 |

  20. Application Sizes Source: Simple line count of Java,XML,MF,C,CPP,H files including comments and excluding test code. 20 2007 JavaOne SM Conference | Session TS-3316 |

  21. Application Size Breakdown 50,000 Source: Simple line count of Java,XML,MF,C,CPP,H files including comments and excluding test code. 21 2007 JavaOne SM Conference | Session TS-3316 |

  22. SPAR - A Swing Rich Client Platform • At a point Imagery got to big for a simple model • I did a lot of research and put together the best technologies of the time • The SPAR framework was born 22 2007 JavaOne SM Conference | Session TS-3316 |

  23. Agenda  Basics  Modularity  Wiring  Communication  Conclusion  Q & A 23 2007 JavaOne SM Conference | Session TS-3316 |

  24. Modularity • The idea of breaking an application down into manageable modules is well known. • It has been tackled in the server space by frameworks like: Java Platform, Enterprise Edition (Java EE platform) • The main form modularity takes in desktop applications is plugin frameworks. 24 2007 JavaOne SM Conference | Session TS-3316 |

  25. Modularity: Solutions • Today • OSGi [Java Specification Request (JSR) 291] ● Eclipse Equinox ● Knopperfish • NetBeans™ Platform • Platonos • JPF • In the next generation Java SE Platform • JSR 277: Java Module System • JSR 294: Improved Modularity Support in the Java Programming Language 25 2007 JavaOne SM Conference | Session TS-3316 |

  26. Modularity: Platonos http://platonos.sourceforge.net • Small light weight plugin framework • Not as fully featured as OSGi etc but smaller and simpler to understand. • Could be a good choice for medium sized applications • Currently on Version 1.0 version 2 in the works • Good support on the mailing lists 26 2007 JavaOne SM Conference | Session TS-3316 |

  27. Modularity: JPF http://jpf.sourceforge.net/ • Another light-weight plug-in framework • Derivation from Eclipse plug-in framework before it went OSGi • Not one I have had personal experience with but looks like there are people using it for serious applications • Recent releases of 1.0.1 and 1.5.0 on 03/07/2007 27 2007 JavaOne SM Conference | Session TS-3316 |

  28. Modularity: NetBeans Platform http://platform.netbeans.org • Robust well proven framework • Many applications out there using it • Good tool support ● New Book on NetBeans Platform Rich Client Programming: Plugging into the NetBeans™ Platform (ISBN: 0132354802) 28 2007 JavaOne SM Conference | Session TS-3316 |

  29. Modularity: OSGi http://www.osgi.org • Huge industry support for the specification • Widely used in many industries such as: cars, cell(mobile) phones, industrial automation, building automation, PDAs, servers, and of course desktop applications with Eclipse and its RCP apps. • Has good support for native code in plugins • Links: • There is a good presentation on Spring and OSGi that covers the basics of OSGi http://www.bejug.org/confluenceBeJUG/display/PARLEYS/Spring%20OSGi • A good reference to OSGi API is the official spec: http://osgi.org/osgi_technology/download_specs.asp The Eclipse OSGi implementation: http://www.eclipse.org/equinox/ • 29 2007 JavaOne SM Conference | Session TS-3316 |

  30. Modularity: JSR 277 and 294 Offer first-class modularity, packaging and deployment support in the next generation Java SE platform. • JSR-294 (superpackage) • Defines linguistic unit of modularity • Information hiding and separate compilation • JSR-277 (Java Module System) • Defines deployment unit of modularity • Versioning scheme, new distribution format, repository, and runtime support • In the future, existing frameworks like OSGi and NetBeans software will be able to be take advantages of these new core functionality. 30 2007 JavaOne SM Conference | Session TS-3316 |

  31. Modularity in the Spar Framework • Provides modularity though plugins • Uses Eclipse OSGi implementation as its engine • In OSGi a plugin is called a Bundle • What is a Bundle: • Basically a bundle is just a Jar file with some extra attributes in its manifest file 31 2007 JavaOne SM Conference | Session TS-3316 |

  32. Modularity: A OSGi Bundle Manifest Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: SPAR UI Bundle-SymbolicName: com.xerto.spar.ui; singleton:=true Bundle-Version: 1.0.0 Bundle-Vendor: XERTO Bundle-Activator: com.xerto.spar.ui.internal.SparUiActivator Export-Package: com.xerto.spar.ui, com.xerto.spar.ui.actions, … Require-Bundle: org.eclipse.core.runtime, com.xerto.spar Bundle-Classpath: ., swing-worker.jar Eclipse-AutoStart: false Spar-Runlevel: 10 32 2007 JavaOne SM Conference | Session TS-3316 |

  33. Modularity: So what does this give you • Simple self contained building block • Forces you to think about contracts(links) • Separate public API from any implementation • Makes it easy to breakdown work • Defined dependencies • Simple start-up ordering 33 2007 JavaOne SM Conference | Session TS-3316 |

  34. Agenda  Basics  Modularity  Wiring  Communication  Conclusion  Q & A 34 2007 JavaOne SM Conference | Session TS-3316 |

  35. Wiring How do you connect all these plugins together • Three types of connections: • First is Class Exports • Plugin ‘A’ exports a public API that is used by plugin ‘B’ • Example: ‘A’ contains some Swing components like a Image Viewer Panel which ‘B’ is then using in its UI 35 2007 JavaOne SM Conference | Session TS-3316 |

  36. Wiring: Class Exports How does one plugin use another plugin’s classes • Class exports are provided by the core of OSGi • Plugin ‘A’ who provides the class needs export that classes package in its manifest: Bundle-Name: Plugin A Bundle-SymbolicName: com.abc.A; singleton:=true Export-Package: com.abc.components.imagepanel • Plugin ‘B: needs to depend on ‘A’ in its manifest: Bundle-Name: Plugin B Bundle-SymbolicName: com.abc.B; singleton:=true Require-Bundle: com.abc.A 36 2007 JavaOne SM Conference | Session TS-3316 |

  37. Wiring: Class Exports import com.abc.components.imagepanel.ImagePanel; public class ExmpleB { private ImagePanel ip = new ImagePanel(); … } 37 2007 JavaOne SM Conference | Session TS-3316 |

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend