Issue 2 in yadic: container chain resolution should always begin from lowest container

5 views
Skip to first unread message

ya...@googlecode.com

unread,
Apr 5, 2011, 10:55:18 AM4/5/11
to ya...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 2 by thomasal...@googlemail.com: container chain resolution
should always begin from lowest container
http://code.google.com/p/yadic/issues/detail?id=2

What steps will reproduce the problem?
1.Make container called parent that has a Wallet and Money class
registered. Wallet depends on Money thru its constructor.
2.Make another container called child that has parent as its resolver.
Register a different Money class in the child container
3.Do child.get(Wallet.class) and assert that the money in it is the child
container money

What is the expected output? What do you see instead?

Would like to see Wallet.class coming from the parent container, and
Money.class coming from the child container. We think its resolving the
Money.class from the parent container. This would enable powerful things.

Mike and Tom.

ya...@googlecode.com

unread,
Apr 5, 2011, 12:42:03 PM4/5/11
to ya...@googlegroups.com
Updates:
Owner: christia...@gmail.com
Cc: daniel.bodart

Comment #1 on issue 2 by christia...@gmail.com: container chain resolution

should always begin from lowest container
http://code.google.com/p/yadic/issues/detail?id=2

Hi Mike and Tom,

I will talk this over with Dan, but I am not sure I agree with your
suggestion.

We were intentionally looking for a 1 way direction from the containers
child -> parent. The reason being the use case for us chaining containers
together was for being able to place each container at different scopes.

ie: child container (at per request scope)
parent container (at per application scope)

Therefore what we would see is that the Money class in the Application
scope container seeks out a dependency at a lower scope (per web request).
This then makes no sense as that dependency would never be called.

To keep things simple, I think we might keep the dependency resolving in a
1 way direction. I do apologise for lack on any documentation around this
feature.

I will talk it over with Dan however and see what we think.

ya...@googlecode.com

unread,
Apr 5, 2011, 3:04:50 PM4/5/11
to ya...@googlegroups.com
Updates:
Status: WontFix

Comment #2 on issue 2 by daniel.bodart: container chain resolution should

always begin from lowest container
http://code.google.com/p/yadic/issues/detail?id=2

Christian is spot on, this has come up a few times and always feels like it
makes sense at some level but it's actually an anti pattern.

Plus it would actually be impossible to do as objects are only constructed
once per scope so having a dependency in a lower scope really does not make
sense.

What you really have is not a dependency but something that should be
passed into the method call of the parent (application) scoped object so
that it can operate on it.

Some other containers (Guice/Spring) allow this kind of thing and it
actually introduces some really nasty thread locking / set mutation issues
which just don't exist in yadic.

Anyway I'm gona mark as won't fix, hope that's okay.

Daniel Worthington-Bodart

unread,
Apr 5, 2011, 3:07:20 PM4/5/11
to ya...@googlegroups.com
When I said "allow this kind of thing" I mean't the parent seeing
child dependency

Christian Blunden

unread,
Apr 5, 2011, 5:51:56 PM4/5/11
to ya...@googlegroups.com
yeah that's what I thought.. 

Stay the course!! Keep it simple ;)

ya...@googlecode.com

unread,
Apr 6, 2011, 4:52:50 AM4/6/11
to ya...@googlegroups.com

Comment #3 on issue 2 by thomasal...@googlemail.com: container chain
resolution should always begin from lowest container
http://code.google.com/p/yadic/issues/detail?id=2

No problem guys this makes perfect sense

Reply all
Reply to author
Forward
0 new messages