> I have
> found very very few circumstances where an entity needed a
> non-transient dependency to something.
> <<
>
> Did you mean persistent or transient?  I need a transient dependency to a
> service.
>

Not surprisingly I am using the definition of transient itself not
refering to a transient vs persistent object. In other words for 95+%
of cases the object does not need to *remember* which service to use,
it just needs to be given one for the duration of an operation. These
can be handled through double dispatch ...

Your code example is slightly off ... the builder should not be
handing the service to the object but should be using the service to
get the data to pass to the object.

On Thu, Mar 26, 2009 at 10:58 AM, Peter Morris <mrpmor...@gmail.com> wrote:
>
> Hi Greg
>
>>>
> While you have done your very best to try to find and edge case
> <<
>
> I'm not actually looking for a corner case here I'm just trying to find a
> way to implement what I currently need, but it does make me wonder about
> injecting dependencies into my domain.  Surely there are circumstances where
> the domain is going to need services injected, as you say like Logging.  How
> would I inject a logging dependency?
>
>>>
> I have
> found very very few circumstances where an entity needed a
> non-transient dependency to something.
> <<
>
> Did you mean persistent or transient?  I need a transient dependency to a
> service.
>
>>>
> Use a builder (nested class) and a private constructor... give the
> builder the service and have the service use the array overload that
> is on the private constructor.
> <<
>
> Do you mean something like this?
>
> public class Song
> {
>    public class SongBuilder
>    {
>        IWordHashService WordHashService;
>        public SongBuilder(IWordHashService wordHashService)
>        {
>            WordHashService = wordHashService;
>        }
>
>        public Song CreateSong(string name)
>        {
>            return new Song(name, WordHashService);
>        }
>    }
>
>
>    IWordHashService WordHashService;
>    private Song(string name, IWordHashService wordHashService)
>    {
>        //Validate Name
>        Name = name;
>        WordHashService = wordHashService;
>    }
>
>    private string name;
>    public string Name
>    {
>        get { return name; }
>    }
> }
>
>
> Pete
> ====
> http://mrpmorris.blogspot.com
>
>
> >
>



-- 
It is the mark of an educated mind to be able to entertain a thought
without accepting it.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to nhusers@googlegroups.com
To unsubscribe from this group, send email to 
nhusers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to