Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use class interface/header for TyphooonAssistedFactoryProvider #176

Closed
jasperblues opened this issue Feb 12, 2014 · 3 comments
Closed

Use class interface/header for TyphooonAssistedFactoryProvider #176

jasperblues opened this issue Feb 12, 2014 · 3 comments

Comments

@jasperblues
Copy link
Member

Instead of having to create a separate protocol for TyphoonAssistedFactoryProvider, could we just use the class' interface/header ?

@jasperblues
Copy link
Member Author

Consider the following duplication:

/**
* Factory for returning a controller with delegate.
*/
@protocol VBRequestRVIControllerFactory

@property(nonatomic, strong, readonly) VBRequestRVIView* rviView;

- (VBRequestRVIViewController*)controllerWithDelegate:(id <VBRequestRVIControllerDelegate>)delegate;

@end


/**
* Controller to solicit required or voluntary (RVI) information before proceeding to checkout.
*/
@interface VBRequestRVIViewController : UIViewController

@property(nonatomic, strong) VBRequestRVIView* rviView;
@property(nonatomic, weak, readonly) id <VBRequestRVIControllerDelegate> delegate;

- (instancetype)initWithRviView:(VBRequestRVIView*)rviView delegate:(id <VBRequestRVIControllerDelegate>)delegate;

@end

@drodriguez
Copy link
Contributor

Initially, no. The trick of using the protocols simplifies the process (and the code) a lot, because we know that the protocol only have creation methods, and the readonly properties are dependencies.

For your case, for example, if we only have the @interface, how will we know the name of the convenience method?… We might take the last word of the class, for example, but that not always work. And how many parts of initWith we should take out? In either case, the user of the class will not have the selector name anywhere, so the compiler will warn everytime, and the autocomplete will not help at all (and those methods should be class methods). The readonly properties also help, because they “reduce” the number of methods present on the @protocol, so wiring up the virtual class is so much easier.

Possible? Yes, but I think sticking to a more traditional approach, even if it implies a little bit of repetition, gives a better solution. Anyway, if you give me an example of how the final usage of the only @interface version of the factory works (how the final user will build instances in code), I may be see what you are getting to.

@jasperblues
Copy link
Member Author

I see. . . let's close this then.

I don't have anything to suggest at this stage . . . was just raising a random (probably dumb) question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants