title: Difference between @Delegate and @Mixin AST transformations in Groovy
body: <p>What's the difference between <a href="http://groovy.codehaus.org/api/groovy/lang/Delegate.html" rel="noreferrer">@Delegate</a> and <a href="http://groovy.codehaus.org/api/groovy/lang/Mixin.html" rel="noreferrer">@Mixin</a> AST transformations in Groovy.</p>
  
  <p>Maybe my question has to do with OO and when apply different patterns, but I use both and I can achieve the same behavior.</p>
  
  <pre><code>class Person {
      String name = "Clark"
      def walk() { "Walk" }
  }
  
  @Mixin(Person)
  class Superhero {
      def fly() { "Fly" }
  }
  
  def superman = new Superhero()
  assert superman.name == "Clark"
  assert superman.walk() == "Walk"
  assert superman.fly() == "Fly"
  </code></pre>
  
  <hr>
  
  <pre><code>class Person {
      String name = "Clark"
      def walk() { "Walk" }
  }
  
  class Superhero {
      @Delegate Person person
      def fly() { "Fly" }
  }
  
  def superman = new Superhero(person: new Person())
  assert superman.name == "Clark"
  assert superman.walk() == "Walk"
  assert superman.fly() == "Fly"
  </code></pre>