2012年5月29日星期二

Datasource 与 Delegate的总结

Datasource 与 Delegate的总结

在Matt Gemmell的API Design文章中,Matt对Objective-c中的Data-Source Protocol和Delegate Protocol进行了总结:

所有的DataSource Protocol在设计上可以总结为:

  • How many things do I have?
  • What's the value for property Y of thing X?

同理,所有的Delegate Protocol也可总结为:

  • Should this thing do that?
  • This thingis about to do that.
  • This thing just did that.

TAG: