Boiling out Boilerplate

Boilerplate

Boilerplate

@interface Foo : NSObject {
  Bar *_bar;
}
@property (retain) Bar *bar;
@end

@implementation Foo
@synthesize bar = _bar;

- (void)dealloc {
  [_bar release];
  [super dealloc];
}
@end

149 chars

Boilerplate

 
public class Foo {

  private Bar bar;

  public Bar getBar() {
    return bar;
  }

  public void setBar(Bar bar) {
    this.bar = bar;
  }
}

98 chars

Boilerplate

 
public class Foo {

  private Bar bar;

  public Bar getBar() {
    return bar;
  }

  public void setBar(Bar bar) {
    this.bar = bar;
  }
}

98 chars

Boilerplate

 
public final class Foo {

  private final Bar bar;

  public Bar getBar() {
    return bar;
  }

  public Foo(Bar bar) {
    this.bar = bar;
  }
}

101 chars

Boilerplate

 
public final class Foo {

  private final Bar bar;

  public Bar getBar() {
    return bar;
  }

  public Foo(Bar bar) {
    this.bar = bar;
  }
}

101 chars

JSR 269

@AutoValue
public abstract class Foo {

  public abstract Bar getBar();

  public static Foo create(Bar bar) {
    return new AutoValue_Foo(bar);
  }
}





119 chars

Boilerplate

 
public final class Foo {

  private final Bar bar;

  public Bar getBar() {
    return bar;
  }

  public Foo(Bar bar) {
    this.bar = bar;
  }
}

101 chars

Lombok

@Value
public class Foo {

  Bar bar;
}









29 chars

Lombok

@Value
public class Foo {

  Bar bar;
}









29 chars

Groovy

 
class Foo {

  Bar bar
}









16 chars

Groovy

@Immutable
class Foo {

  Bar bar
}









26 chars

Talk is cheap,

show me the code!

Thank You && Q || A

Made with Slides.com