Swiftで fluentなインターフェースを実装する

A3e610d8bcbd1089a39b1a8caf972ab6?s=47 sozorogami
February 18, 2015

Swiftで fluentなインターフェースを実装する

fluentなAPIを持った色ジェネレーターをSwiftで実装した話。

参考文献
http://martinfowler.com/bliki/FluentInterface.html
http://en.wikipedia.org/wiki/Fluent_interface

A3e610d8bcbd1089a39b1a8caf972ab6?s=128

sozorogami

February 18, 2015
Tweet

Transcript

  1. 4.

    private void makeNormal(Customer customer) { Order o1 = new Order();

    customer.addOrder(o1); OrderLine line1 = new OrderLine(6, Product.find("TAL")); o1.addLine(line1); OrderLine line2 = new OrderLine(5, Product.find("HPK")); o1.addLine(line2); OrderLine line3 = new OrderLine(3, Product.find("LGV")); o1.addLine(line3); line2.setSkippable(true); o1.setRush(true); } ຊདྷ
  2. 6.

    Customer *customer = [Customer new]; [[[[[[customer newOrder] withAmount:@6 ofItem:@"TAL"] withAmount:@5

    ofItem:@"HPK"] skippable] withAmount:@3 ofItem:@"LGV"] priorityRush]; 0CK$Ͱ͸ɾɾɾ ƅЧƅʀ)