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

"Quick Start" is not ok (?) #273

Closed
7ynk3r opened this issue Oct 31, 2014 · 3 comments
Closed

"Quick Start" is not ok (?) #273

7ynk3r opened this issue Oct 31, 2014 · 3 comments

Comments

@7ynk3r
Copy link

7ynk3r commented Oct 31, 2014

I just looked carefully to the quick start example and I discovered something obvious

- (Knight*)basicKnight
{
    return [TyphoonDefinition withClass:[Knight class] configuration:^(TyphoonDefinition* definition) {
        [definition useInitializer:@selector(initWithQuest:) parameters:^(TyphoonMethod *initializer) {
            [initializer injectParameterWith:[self defaultQuest]];
        }];
    }];
}

basicKnight is not returning an instance of Knight but instead an instance of TyphoonDefinition. Why are we using that as an example? Why not simply return the correct type? Am I missing something?

Happy weekend!

@jasperblues
Copy link
Member

It is in fact correct, though it should have clarification. We do this because:

  • at build-time TyphoonAssembly methods rerun definitions - recipes for assuming an object from its config and collaborators.
  • at run-time the assembly interface is used to return built components.

We used to have assembly methods return type 'is' but it worked well to have them return the type that will be produced - for IDE code completion without casting, etc. Resolving components from the assembly is where type matters the most.

This approach only works in Objective-C, in Swift the strict typing rules don't allow is kind of meta programming.

Given this is unusual we do need a clear explanation. Goals:

  • get people started as quickly as possible, without overwhelming info
  • at the same time don't leave them confused

It seems current quick start needs a little more of the 2nd point.

@7ynk3r 7ynk3r closed this as completed Nov 1, 2014
@7ynk3r
Copy link
Author

7ynk3r commented Nov 1, 2014

Thanks for the clarification.

@jasperblues
Copy link
Member

You're welcome. Sorry for the typing mistakes above:

  • Rerun = return
  • Exabation = explanation

;) typing on iphone (fixed now)

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