Saturday 15 March 2014

ios - Is DataSource Pattern used with UITableView an example of dependency injection? -


This is not tightly coupled with tableview, information about configuration of TableView is injected through the implementation of the UITableViewDataSource Protocol.

This is a good example of dependency injection in iOS development

Yes, This can be considered as an example of dependency injection. Dependency injection is a simple definition:

Dependency injection is a design pattern where the dependencies and associations of an object are set by an external entity, not by itself. From the UITableViewDataSource protocol, we actually separate UITableViewController from the data source, which means it needs to do its job That class, which creates UITableViewController , can configure it with any data source, its reusability and improvements in testability (two common goals of dependency injection)

No comments:

Post a Comment