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.
posted @ 2012-05-29 15:56  wupher  阅读(1248)  评论(0编辑  收藏  举报