Your SlideShare is downloading. ×
0
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Codegeneration With Xtend

12,382

Published on

Why you should implement Code Generators with Xtend.

Why you should implement Code Generators with Xtend.

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
12,382
On Slideshare
0
From Embeds
0
Number of Embeds
19
Actions
Shares
0
Downloads
28
Comments
0
Likes
4
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Code Generation withSven Efftinge - itemis
  • 2. What is it?
  • 3. Successor to XpandBuilt with
  • 4. Why ?much faster (as fast as Java)much better IDE supportgeneralized set of featuressimpler
  • 5. Code Generation Essentials
  • 6. Template Expression(aka string concatenation)same syntax as in Xpandjust an expressiongreyspace support!
  • 7. static typingsimply Javano pluggable type systemcan be emulated withactive annotations
  • 8. longitude & latitude
  • 9. higher-order functionsmap, filter, flatten, etc.it’s just library!
  • 10. class TypeProviderExample { def getHourlyData() { data.weather.hourlys } def getTimeWithHighestSwell() { hourlyData.sortBy[swellheightM].head.time } def getAverageWindSpeed() { hourlyData.map[windspeedkmph].reduce[a,b|a+b] / hourlyData.size }}
  • 11. dynamic dispatch
  • 12. dynamic dispatch
  • 13. dynamic dispatcheasily debuggable & extendable
  • 14. dynamic dispatch def generate(ETypedElement e) { switch e { EAttribute : attribute EReference case e.isContainment: containment reference EReference : reference EOperation : operation default : throw new IllegalArgumentException("not handled : "+e) } }dispatch over type and statefirst comefirst serve
  • 15. modularization
  • 16. AOP?
  • 17. Dependency Injection!
  • 18. class MainGenerator { @Inject extension EcoreGen ecoreGenerator def doGenerate(EClass it) class «name» { «FOR f : EStructuralFeatures» «f.generate» «ENDFOR» } }class EcoreGen { def dispatch generate(EAttribute attribute) generate attribute def dispatch generate(EReference reference) generate reference def dispatch generate(EOperation operation) generate operation }declare the dependency
  • 19. class MySpecialEcoreGen extends EcoreGen { override dispatch generate(EAttribute attribute) special EAttribute def dispatch generate(EParameter param) parameter }class CustomizedGenerator { def static void main(String[] args) { val injector = Guice::createInjector [ bind(typeof(EcoreGen)).to(typeof(MySpecialEcoreGen)) ] val mainGenerator = injector.getInstance(typeof(MainGenerator)) mainGenerator.doGenerate(EcorePackage::eINSTANCE.EClass) }}Extend the class you want to modifyUse Guice to wire up the generator
  • 20. content assistsyntax coloringquick assist outlinerename refactoringformatingcall hierarchytype hierarchyextract methoddebuggingetc...IDE Support
  • 21. But why always a DSL?
  • 22. MyBeanString valueclass
  • 23. MyBeanString valueclass {}@Observable
  • 24. future worktooling via librarymore macro supportembedded languagessnappiness!
  • 25. Thank you!@svenefftinge / @xtext / @xtendlang (c) 2013 by

×