I am wondering which of the following would be the correct use / implementation in Objective-C of a service oriented design:
The first version refers to static languages using protocols (interfaces):
id<CloudServices> myService = [ServiceProvider serviceWithProtocol:@protocol(CloudServices)];
The second version does not use protocols, relying on the fact that Objective-C is actually dynamic:
CloudServices *myService = [ServiceProvider serviceWithClass:[CloudServices class]];
Obviously, the difference is that CloudServices is an interface or protocol, and we mean that ServiceProvider can be configured to return different implementations of CloudServices.
So my question is which style to choose, and why?
Thank.
Moszi source
share