Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Java Code Generation for Productivity

4,199 views

Published on

Using code generation to enhance developer productivity with Java

Published in: Technology
  • Be the first to comment

Java Code Generation for Productivity

  1. 1. Practical Code Generation: Java Productivity Enhancement <ul><ul><li>David Noble </li></ul></ul><ul><ul><li>[email_address] </li></ul></ul><ul><ul><li>Sr. Solutions Architect, Exist Global </li></ul></ul><ul><ul><li>San Gabriel Valley Java Users Group </li></ul></ul><ul><ul><li>http://www.sgvjug.org/ </li></ul></ul><ul><ul><li>February 25, 2008 </li></ul></ul>
  2. 2. Target <ul><li>Faster development </li></ul><ul><li>Less defects </li></ul>http://flickr.com/photos/ntang/21736774
  3. 3. Target http://flickr.com/photos/ntang/21736774 Tools Practices Productivity
  4. 4. Java <ul><li>public List getIds(List items) { </li></ul><ul><li>List result = new ArrayList(); </li></ul><ul><li>Iterator itemIterator = items.iterator(); </li></ul><ul><li>while (itemIterator.hasNext()) { </li></ul><ul><li>item = (Item) itemIterator.next(); </li></ul><ul><li>result.add(item.getId()); </li></ul><ul><li>} </li></ul><ul><li>return result; </li></ul><ul><li>} </li></ul>Example from Matt Good @ matt-good.net
  5. 5. Java <ul><li>public List<ItemId> getIds(List<Item> items) { </li></ul><ul><li>List<ItemId> result = new ArrayList<ItemId>(); </li></ul><ul><li>for (Item item : items) { </li></ul><ul><li>result.add(item.getId()); </li></ul><ul><li>} </li></ul><ul><li>return result; </li></ul><ul><li>} </li></ul>Example from Matt Good @ matt-good.net
  6. 6. Python <ul><li>def get_ids(items): </li></ul><ul><li>return [item.id for item in items] </li></ul>
  7. 7. Verbosity <ul><li>“ Succinctness is power” </li></ul><ul><ul><li>Paul Graham [1] </li></ul></ul><ul><li>Case study [citation needed] </li></ul><ul><ul><li>Yellowpages.com </li></ul></ul><ul><ul><li>Originally in Java: 100 KLOC </li></ul></ul><ul><ul><li>Converted to Rails: 10 KLOC </li></ul></ul><ul><ul><ul><li>[1] http://www.paulgraham.com/power.html </li></ul></ul></ul>
  8. 8. Defect Rates <ul><li>Bugs/LOC is basically constant </li></ul><ul><ul><li>CMU study [citation needed] </li></ul></ul><ul><li>LOC/day is basically constant </li></ul><ul><ul><li>Fred Brooks </li></ul></ul>
  9. 9. Syntax <ul><li>Declarations </li></ul><ul><li>Casting </li></ul><ul><li>Generics </li></ul><ul><li>Data structures </li></ul><ul><li>Helper classes </li></ul>
  10. 10. Meta-programming Issues <ul><li>Annotations </li></ul><ul><li>Reflection </li></ul><ul><li>Aspect-Oriented Programming (AOP) </li></ul><ul><li>Bytecode manipulation </li></ul>
  11. 11. Startup Weekend <ul><li>One weekend to launch </li></ul><ul><li>Over a dozen companies started </li></ul><ul><li>Only 1 chose Java </li></ul>
  12. 12. DEMO Rails web application
  13. 13. Rails Productivity <ul><li>Project generation </li></ul><ul><li>File generation </li></ul><ul><li>Model-driven framework </li></ul><ul><li>Meta-programming </li></ul>
  14. 14. DEMO Basic Java application
  15. 15. Java Productivity: IDE <ul><li>Project generation </li></ul><ul><li>File generation </li></ul><ul><li>Code snippet generation </li></ul>
  16. 16. Java Productivity: Language <ul><li>Annotations (JSR 175) </li></ul><ul><ul><li>Metadata </li></ul></ul><ul><ul><li>Design time for tools </li></ul></ul><ul><ul><li>Execution time </li></ul></ul>
  17. 17. Java Productivity: Framework <ul><li>Model-driven frameworks </li></ul><ul><ul><li>Grails </li></ul></ul><ul><ul><li>Wicket </li></ul></ul><ul><ul><li>NakedObjects </li></ul></ul><ul><ul><li>OpenXava </li></ul></ul>
  18. 18. Java Productivity: AOP <ul><li>Aspect - feature </li></ul><ul><li>Advice - behavior </li></ul><ul><li>Joinpoint - execution trigger </li></ul><ul><li>Pointcut - set of joinpoints </li></ul><ul><li>Targets - objects to apply aspects to </li></ul><ul><li>Introduction - add methods to object </li></ul>
  19. 19. Bytecode Manipulation <ul><li>Example: persistence injection </li></ul><ul><ul><li>Hibernate </li></ul></ul><ul><ul><li>TopLink </li></ul></ul><ul><li>Libraries, etc </li></ul><ul><ul><li>ASM, BCEL, CGLIB, Javassist, JiBX </li></ul></ul>
  20. 20. DEMO AppFuse
  21. 21. DEMO GUI Builder
  22. 22. SOAP Web Services <ul><li>WSDL to Java </li></ul><ul><li>Java to WSDL </li></ul>
  23. 23. Application Generators <ul><li>CASE revisited </li></ul>
  24. 24. Resources
  25. 25. Resources <ul><li>Code Generation Network </li></ul><ul><ul><li>http://codegeneration.net/ </li></ul></ul>
  26. 26. Resources <ul><li>Eclipse macros </li></ul><ul><ul><li>Window > Preferences > Java > Editor > Templates </li></ul></ul><ul><li>Annotations </li></ul><ul><ul><li>http://java.sun.com/javase/6/docs/technotes/guides/language/annotations.html </li></ul></ul><ul><ul><li>http://www.developer.com/java/other/article.php/3556176 </li></ul></ul><ul><ul><li>http://jcp.org/en/jsr/detail?id=175 </li></ul></ul><ul><li>Maven archetypes </li></ul><ul><ul><li>http://maven.apache.org/guides/introduction/introduction-to-archetypes.html </li></ul></ul>
  27. 27. Resources <ul><li>AppFuse </li></ul><ul><ul><li>http://appfuse.org/display/APF/AppFuse+Maven+Plugin </li></ul></ul><ul><li>GWT </li></ul><ul><ul><li>http://code.google.com/webtoolkit/ </li></ul></ul>
  28. 28. Resources <ul><li>Wicket </li></ul><ul><ul><li>http://wicket.apache.org/ </li></ul></ul><ul><li>Grails </li></ul><ul><ul><li>http://grails.org/ </li></ul></ul><ul><li>NakedObjects </li></ul><ul><ul><li>http://www.nakedobjects.org/ </li></ul></ul>
  29. 29. Resources <ul><li>Metro (JAX-WS et al) </li></ul><ul><ul><li>https://metro.dev.java.net/ </li></ul></ul><ul><li>Axis2 </li></ul><ul><ul><li>http://ws.apache.org/axis2/ </li></ul></ul><ul><li>CXF (formerly XFire) </li></ul><ul><ul><li>http://cxf.apache.org/ </li></ul></ul>
  30. 30. Resources <ul><li>Netbeans Matisse </li></ul><ul><ul><li>http://www.netbeans.org/features/java/swing.html </li></ul></ul><ul><li>Eclipse VE </li></ul><ul><ul><li>http://wiki.eclipse.org/VE </li></ul></ul>
  31. 31. Resources <ul><li>AOP (Aspect Oriented Programming) </li></ul><ul><li>AspectJ </li></ul><ul><ul><li>http://www.eclipse.org/aspectj/ </li></ul></ul><ul><li>JBoss AOP </li></ul><ul><ul><li>http://www.jboss.org/jbossaop/ </li></ul></ul><ul><li>Spring </li></ul><ul><ul><li>http://springframework.org/about </li></ul></ul>
  32. 32. Resources <ul><li>Eclipse JET </li></ul><ul><ul><li>http://www.eclipse.org/modeling/m2t/?project=jet </li></ul></ul><ul><li>Eclipse EMF </li></ul><ul><ul><li>http://www.eclipse.org/modeling/emf/ </li></ul></ul>
  33. 33. Resources <ul><li>Sculptor </li></ul><ul><ul><li>http://fornax-platform.org/cp/display/fornax/Sculptor+(CSC) </li></ul></ul><ul><ul><li>http://www.theserverside.com/tt/articles/article.tss?l=ProductivityWithSculptor </li></ul></ul><ul><li>OptimalJ </li></ul><ul><ul><li>http://frontline.compuware.com/javacentral/tools/ </li></ul></ul>
  34. 34. Resources <ul><li>MDA (model driven architecture) </li></ul><ul><ul><li>http://www.omg.org/mda/ </li></ul></ul><ul><li>Executable UML </li></ul><ul><ul><li>http://en.wikipedia.org/wiki/Executable_UML </li></ul></ul>
  35. 35. DISCUSSION Productivity, practices, tools Thanks for coming! David Noble [email_address]

×