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.

Groovy MOPping

925 views

Published on

Every developer dreams about big red button to do everything he needs. MOP (Metaobject protocol) in Groovy is a way to get close to that dream. There is a presentation of meta programming concepts in Groovy and what benefits you can get from it.

Published in: Technology
  • Be the first to comment

Groovy MOPping

  1. 1. Groovy MOPping Izzet Mustafayev@EPAM Systems @webdizz http://webdizz.name
  2. 2. this is me ● SA at EPAM Systems ● primary skill Java ● hands-on-coding with Ruby, Groovy, some Scala ● passion about agile, clean code practices and devops
  3. 3. agenda ● Groovy ● MOP... what? ● AOP ● method injection/synthesis ● AST ● summary ● q&a
  4. 4. Groovy
  5. 5. Groovy is an agile dynamic language
  6. 6. Java is a Groovy but Groovy is not Java
  7. 7. Groovy supports DSL
  8. 8. Groovy provides statically type check
  9. 9. MOP...?
  10. 10. MOP Example GORM class Person { String name Integer age Date lastVisit } ​ Person.findByName('Jack')
  11. 11. Groovy Object package groovy.lang; public interface GroovyObject { Object invokeMethod(String name, Object args); Object getProperty(String property); void setProperty(String property, Object newValue); MetaClass getMetaClass(); void setMetaClass(MetaClass metaClass); }
  12. 12. Object operation str = 'hello' method = str.metaClass.getMetaMethod ('toUpperCase') ​ println method.invoke(str) // HELLO
  13. 13. AOP
  14. 14. groovy.lang.GroovyInterceptable#invokeMethod
  15. 15. groovy.lang.MetaClass#invokeMethod
  16. 16. method injection
  17. 17. Category
  18. 18. ExpandoMetaClass
  19. 19. Class Instance
  20. 20. Mixing
  21. 21. method synthesis
  22. 22. methodMissing()
  23. 23. ExpandoMetaClass
  24. 24. AST transformations
  25. 25. interception
  26. 26. injection
  27. 27. summary
  28. 28. DSL
  29. 29. Source Analysis
  30. 30. Dependency Management
  31. 31. references ● Groovy http://groovy.codehaus.org/ ● CodeNarc http://codenarc.sourceforge.net/ ● Gradle http://www.gradle.org/ ● Gant http://gant.codehaus.org/ ● Writting DSL http://groovy.codehaus.org/Writing+DomainSpecific+Languages ● Dynamic Groovy http://groovy.codehaus. org/Dynamic+Groovy ● Demo sources https://github.com/webdizz/groovy-mopping
  32. 32. q&a
  33. 33. thank you! Groovy MOPping Izzet Mustafayev@EPAM Systems @webdizz http://webdizz.name

×