-
Notifications
You must be signed in to change notification settings - Fork 268
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
Changing Definition creation API to be more compact #185
Comments
I can see the merit in making it more compact, however I was a bit hesitant about:
Still . . unless someone will raise a red flag, I say let's do it. |
Benefits:
|
I tried to implement that I want: compact API as possible. Finally I got API: @interface TyphoonDefinition (ExperimentalAPI)
- (void)_injectProperty:(SEL)selector;
- (void)_injectProperty:(SEL)selector with:(id)injection;
- (id)_injectionFromSelector:(SEL)factorySelector;
- (id)_injectionFromKeyPath:(NSString *)keyPath;
@end
id InjectionFromStringRepresentation(NSString *string);
id InjectionFromCollection(void (^collection)(TyphoonPropertyInjectedAsCollection *collectionBuilder)); Here is example of usage: //object
[self _injectProperty:@selector(property) with:@"object"];
//number value
[self _injectProperty:@selector(property) with:@(3.1415f)];
//definition
[self _injectProperty:@selector(property) with:[self anotherDefinition]];
//assembly (i.e. ComponentFactory )
[self _injectProperty:@selector(property) with:self];
//proxy assembly (i.e. ComponentFactory )
[self _injectProperty:@selector(property) with:self.collaboratingAssembly];
//NSValue struct
[self _injectProperty:@selector(property) with:[NSValue valueWithRange:NSMakeRange(0, 20)]];
//Result of invoking factory method on resolved definition
[self _injectProperty:@selector(property) with:[[self anotherDefinition] _injectionFromSelector:@selector(factoryMethod)]];
// Value from string representation
[self _injectProperty:@selector(property) with:InjectionFromStringRepresentation(@"3.1415")];
//Collection
[self _injectProperty:@selector(property) with:InjectionFromCollection(^(TyphoonPropertyInjectedAsCollection *collectionBuilder) {
[collectionBuilder addItemWithDefinition:[self anotherDefinition]];
[collectionBuilder addItemWithText:@"3.1415" requiredType:[NSNumber class]];
})]; I'm not sure that |
I didn't test my implementation yet (but I think it should works :-) ) because I want to discuss result API first. |
Looks very nice. . overall there's less to remember. And it reads better. 👍 |
Does anyone else have an opinion on this API? |
Just one comment. I haven’t look at the code “in place” but from the diff it seems to be something internal, not destined for the final user, right? If so, we should define Other than that, nothing else to comment. |
I agree about functions, but if we do shorthand we loose IDE autocompletion for function arguments (for example collection builder block).. |
Between losing auto-complete and seeing the word 'Typhoon' in front, I'd probably choose the latter. . |
Finally I did really compact API. Without any C functions.. just |
This is über-cool!!!! Great work alekesy! 🎱 |
Results merged to master. This issue can be closed after review |
I had a look at it. I like it, really clean. And I agree it will be much simpler for the end-user. Only thing, minor one: Probably a good idea to create a separate issue for updating the Wiki for this rather big change before the next release. |
Thanks. |
@eriksundin , I've added a Typhoon 2.0 release checklist #193 |
All good as far as I'm concerned. One comment: TyphoonConfig assumes the prefix for a TyphoonPropertyPlaceholderConfigurer is the default ${} . . . this is probably fine. |
@jasperblues Checklist. 👍 I can agree that documentation takes up a lot of space in some API classes. Although, the nice thing that come out of it is the generated documentation on http://www.typhoonframework.org/docs/latest/api/modules.html. |
The nice thing about the API docs also, is that they're indexed by Google, unlike the wiki pages in Github. . . . So I can type: TyphoonAssembly just in Google and get the docs, which I like. The rendering in the IDE looks a little cluttered. I read that Xcode5 is supposed to render the markup in to rich-text - not sure how it works. Same feature is coming in AppCode.
|
Ok. Thanks for comments. Let's keep as is. |
If no comments from @drodriguez or @rhgills , lets close. . . waiting 48 hours. |
👍 |
Looks great to me. Good work alekesy! 👍 |
Ideally I want
Where 'something' in method
can be:
New methods:
should be removed and replaced by something like (method names are bad, let's think more)
I.e.
The text was updated successfully, but these errors were encountered: