Re: When and where to use Visitor Pattern?
- From: "Daniel Parker" <danielaparker@spam?nothanks.windupbird.com>
- Date: Wed, 27 Apr 2005 19:23:25 -0400
<Nicholls.Mark@xxxxxxxxx> wrote in message
news:1114618156.808945.16930@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> if 'instanceof' is some form of reflection,
It's dynamic type checking, querying for the existence of interfaces, I
don't think you would call that reflection.
> then there are plenty of
> people (well at least me) who prefer the type safety of visitors....in
> fact in some sense I view visitors as typesafe reflection.
>
As typesafe casting, perhaps? Without the runtime cost of an instanceof or
typeof? I do agree with this characterization, I think it's correct.
But there's not really a material difference between the two approaches,
apart from matters of clarity. In both cases you have to enumerate all the
types of interest, and using instanceof/typeof is type safe.
> less clutter? I don't think that the visit method is particularly
> prohibitive in terms of clutter, though I accept that visitors can
> fracture your code into tiny itty bitty bits.
>
Yeah, I guess my main issue is that I find code written to the visitor
pattern to be less clear than code written in alternative styles, and I have
to confess to having a distaste for "tiny itty bitty bits".
Regards,
Daniel Parker
.
- References:
- When and where to use Visitor Pattern?
- From: Sam Hwang
- Re: When and where to use Visitor Pattern?
- From: Ilja Preuß
- Re: When and where to use Visitor Pattern?
- From: Rich MacDonald
- Re: When and where to use Visitor Pattern?
- From: Daniel Parker
- Re: When and where to use Visitor Pattern?
- From: Nicholls . Mark
- When and where to use Visitor Pattern?
- Prev by Date: Re: Lahman, how ya doing?
- Next by Date: Re: When and where to use Visitor Pattern?
- Previous by thread: Re: When and where to use Visitor Pattern?
- Next by thread: Re: When and where to use Visitor Pattern?
- Index(es):
Relevant Pages
|