As3 Code Gen From Uml

2,585 views

Published on

Slides from an SF presentation on generating AS3 code from UML using some open source tools that I contributed to.

Published in: Technology
  • Be the first to comment

As3 Code Gen From Uml

  1. 1. GENERATING AS3 CODE Adam Breindel [email_address]
  2. 2. Motivation <ul><li>Porting a Large App </li></ul><ul><li>Multiple Object “Projections” </li></ul><ul><ul><li>Infrastructure domain </li></ul></ul><ul><ul><li>Rendering domain </li></ul></ul><ul><ul><li>Conceptual (user-facing) problem domain </li></ul></ul><ul><li>User facing domain leant to UML modeling </li></ul><ul><li>Made several tries to get it right -- rewriting </li></ul>
  3. 3. Solution <ul><li>We’re discussing with UML on a whiteboard </li></ul><ul><li>So… </li></ul><ul><li>Let’s use a UML tool and gen code </li></ul><ul><li>Quick Demo </li></ul>
  4. 4. Lots of UML tools <ul><li>Legacy of the process-based OO of the 90s </li></ul><ul><li>Cost cutting and move to agile processes results in many light, free tools </li></ul>
  5. 5. Not a Lot of AS3 <ul><li>New langage </li></ul><ul><li>Owned by one vendor </li></ul><ul><li>Was 1 commercial tool (now 2 or so) </li></ul><ul><li>Not free: $300-$400 per seat </li></ul>
  6. 6. Hack a UML Tool… <ul><li>Picked Cay Horstmann’s Violet UML </li></ul><ul><ul><li>Very lightweight! </li></ul></ul><ul><ul><li>Used in academia </li></ul></ul><ul><ul><li>All Java, appeared easy to hack </li></ul></ul><ul><ul><li>Not the only choice, but fine for our purpose </li></ul></ul>
  7. 7. … to Generate ActionScript 3 <ul><li>Super Hack Way </li></ul><ul><ul><li>Write code to print strings out to files </li></ul></ul><ul><ul><li>Doesn’t leverage language structure to DRY </li></ul></ul><ul><ul><li>Has no hope of reverse engineering code – requires totally separate parser </li></ul></ul><ul><li>Sophistimicated Way </li></ul><ul><ul><li>Use a meta-language API built with a parser generator … kind of like using half the guts of a compiler </li></ul></ul>
  8. 8. Enter Metaas <ul><li>By David Holroyd </li></ul><ul><li>Java API wrapping an ANTLR-generated AS3 processor </li></ul><ul><li>http://www.badgers-in-foil.co.uk/projects/metaas/ </li></ul>
  9. 9. Required Minimal Monkeying <ul><li>Building Metaas from source to get latest fixes requires ANTLR </li></ul><ul><li>ANTLR was in between versions 2 and 3 </li></ul><ul><li>But now Metaas has a new version (0.8) </li></ul><ul><li>And ANTLR is most definitely in v3 </li></ul><ul><li>And anyway ANTLR is exceptionally cool! </li></ul>
  10. 10. Grammar Tool (Eye Candy)
  11. 11. Simple-ish Integration <ul><li>Add a menu item for export to AS3 </li></ul><ul><li>Find all the objects and relationships </li></ul><ul><li>Generate an object for each class, interface </li></ul><ul><li>Modify the class declaration based on </li></ul><ul><ul><li>Packages in diagrams </li></ul></ul><ul><ul><li>Parent classes / interfaces in diagram </li></ul></ul><ul><li>For each class or interface </li></ul><ul><ul><li>Generate methods, fields, properties </li></ul></ul><ul><ul><li>Flush to file </li></ul></ul>
  12. 12. Upgrade <ul><li>Updated to use re-skinned extended version of Violet </li></ul><ul><li>Can run via JNLP or possibly as Eclipse plug-in </li></ul>
  13. 13. Feature List <ul><li>Packages </li></ul><ul><li>Classes </li></ul><ul><li>Interfaces </li></ul><ul><li>Visibility modifiers (+, -, #, empty) </li></ul><ul><li>Arg types, return types </li></ul><ul><li>Field-wrapping properties (@) </li></ul><ul><li>Aggregation (as Array) </li></ul><ul><li>Inheritance (extends, implements) </li></ul>
  14. 14. Let’s Play a Little More <ul><li>This is open source </li></ul><ul><li>It is far from perfect </li></ul><ul><li>So add whatever you like! </li></ul><ul><li>Project page: http://selfmummy.com/vasgen/ </li></ul>
  15. 15. Questions? <ul><li>My contact info: </li></ul><ul><ul><li>Adam Breindel / Ind. Consultant </li></ul></ul><ul><ul><li>[email_address] </li></ul></ul><ul><ul><li>http://skipmeamadeus.blogspot.com </li></ul></ul>

×