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

Documentation Injection by Reference examples are hard to follow #300

Closed
fatuhoku opened this issue Dec 20, 2014 · 5 comments
Closed

Documentation Injection by Reference examples are hard to follow #300

fatuhoku opened this issue Dec 20, 2014 · 5 comments

Comments

@fatuhoku
Copy link
Contributor

As a relative newcomer, reading this wiki section about Injection by Reference, I read it and still have little idea of how injection by reference works, mainly because the examples are so arbitrary.

For instance, for the following code snippet:

    - (Knight *)knight
    {
        return [TyphoonDefinition withClass:[Knight class] configuration:^(TyphoonDefinition *definition) {
            [definition injectProperty:@selector(quest) with:[self defaultQuest]];
        }];
    }

    - (Knight *)knightWithQuestFromAnotherModule
    {
        return [TyphoonDefinition withClass:[Knight class] configuration:^(TyphoonDefinition *definition) {
            [definition injectProperty:@selector(quest) with:[_questModule scaryQuest]];
        }];
    }

There huge questions in my mind

  • "What on earth is [self defaultQuest]? Where did it come from?" — after some digging I found it's actually defined from the first page... this assumes the user must read all the documentation examples in order to make any sense of the examples
  • "Well, if I'm supposed to define [self defaultQuest] myself, could I do:
- (Quest *)defaultQuest {
    return [Quest new];
}

...?" — there's no indication that defaultQuest needs to return a TyphoonDefinition. In fact, what actually happens if the user does this?

  • "What on earth is _questModule?" — I could have guessed that [self defaultQuest] is supposed to be a Quest, or a TyphoonDefinition that tells us how a Quest object should be set up. But whoa, what's a Module (see Documentation refers to 'Modules' but there's no such concept in Typhoon code #299)? I was completely lost at this point. In hindsight, of course _questModule is simply yet another TyphoonAssembly. Can we stop calling Assemblies 'Modules' already?
@fatuhoku fatuhoku changed the title Documentation examples hard to follow Documentation Injection by Reference examples are hard to follow Dec 20, 2014
@jasperblues
Copy link
Member

@fatuhoku Wow, that was pretty messed up. Thanks for reporting.

  • Fixed the example so that it shows both the object with dependency (knight), along with the dependency to be injected (quest).
  • Removed the example showing injecting something from another assembly, but left the 'see also' link. Folks can read about it there.

@jasperblues
Copy link
Member

@fatuhoku Added a note on first page that each assembly method returns a TyphoonDefinition

@jasperblues
Copy link
Member

@fatuhoku Ready for review, we can continue on this ticket or raise new issues.

@fatuhoku
Copy link
Contributor Author

Hiya, the new wiki pages have certainly addressed the concerns I had raised so 🍻 Cheers. =]

@jasperblues
Copy link
Member

Cheers. We appreciate your help. Do you see other areas that remain unclear?

Sent from my iPhone

On Dec 24, 2014, at 5:14 AM, Hok Shun Poon notifications@github.com wrote:

Hiya, the new wiki pages have certainly addressed the concerns I had raised so Cheers. =]


Reply to this email directly or view it on GitHub.

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

No branches or pull requests

2 participants