Skip to content
This repository has been archived by the owner on Dec 6, 2017. It is now read-only.

Di docs #98

Closed
wants to merge 5 commits into from
Closed

Di docs #98

wants to merge 5 commits into from

Conversation

trinarytree
Copy link

No description provided.

Chris Calabro added 4 commits April 25, 2014 13:35
all we really want for Key is instance control.
the previous implementation would cause horrible problems for pairs of
(type, annotation)s where the hash codes collide,
which is easy given the poor choice of hash function
(a sum of the hash codes of the components).
also, lastKeyId was a misnomer, since it actually held the number of instances.
this wrong name caused off-by-1 usage, which didn't cause a bug,
but was misleading and wasted a little memory.
i believe this implementation to be vastly superior in memory usage
since it returns cached Keys instead of creating new, equivalent ones.
added and simplified Key tests.

docs(Injector, etc): Provided accurate docs in many places.

refactor(ResolutionContext): Small changes.

- added ResolutionContext type annotation where it was missing.
- changed const ResolutionContext to new, since const doesn't work
  in general (it only works when the key is null).
- simplified docs to ResolutionContext and made them more useful (imo).

refactor(base_injector.dart): Rename _ProviderWithDefiningInjector...

to shorter _ProviderWithInjector since it's just a pair.
@@ -25,7 +25,7 @@ class DynamicInjector extends BaseInjector {
new DynamicInjector._fromParent(modules, this, name: name);

Object newInstanceOf(Type type, ObjectFactory objFactory, Injector requestor,
resolving) {
ResolutionContext resolving) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@vicb
Copy link
Contributor

vicb commented Apr 28, 2014

Most of the changes are great some are useless IMO.

Could you please squash your commits and improve the commit comments ? (you can then force push to this same branch, no need to open a new PR).

Ideally I would see 3 commits here:

  • doc():...
  • fix():...
  • perf():....

@vicb
Copy link
Contributor

vicb commented Apr 28, 2014

fixes #94 replaces #96

@vicb
Copy link
Contributor

vicb commented Apr 28, 2014

You also might want to update the PR title

@mvuksano
Copy link
Contributor

@vicb You said this replaces #97 but I can see anything on that topic in this PR. Am I blind? :)

@vicb
Copy link
Contributor

vicb commented Apr 28, 2014

@markovuksanovic wrong PR number, will update!

Map<int, int> _hashToKey = {};

/**
* Key to which an [Injector] binds a [Provider]. This is a pair consisting of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You use Provider a lot in comments... Provider has always been an internal implementation detail, it's not exposed in any public API. I would rather use the term "binding".

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we discussed this offline, but posting here for posterity:
Provider is publicly exposed via NoProviderError and Module.bindings, which is a map from int to Provider. it's also tedious to try to explain most of this di design without this concept. e.g. an injector binds a key to a ... what? not an instance.

it is an admirable goal to see if one can hide this concept, but i think it would require a substantial redesign. if that happens, just alter the docs at that point.

@pavelgj
Copy link
Contributor

pavelgj commented May 5, 2014

Thanks, merged via f673267 with perf cleanup 0930b37

@pavelgj pavelgj closed this May 5, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants