[antlr-interest] Article against TreeWalkers

Andy Tripp antlr at jazillian.com
Fri Mar 10 09:21:34 PST 2006


Anthony Youngman wrote:

>:-)
>
>I had intended to send this reply in response to the switch/interface
>post.
>
>In my studies I came across something that said "only 50% progress from
>concrete to abstract thought". Okay, I guess most of us here are in the
>50% that have progressed.
>
>But a switch statement is a far more concrete construct than an
>interface. I'm fine with metadata, but I find Antlr pushing me into
>realms I have problems with.
>
>  
>
I'd like to replay the last 15 minutes of my life stream of conciousness...

I wonder what this whole "interfaces are better than switches" thing is 
about...must be a design pattern
...google "switch antipattern"...poke around a bit...Aha! The Strategy 
Pattern...break out the GoF
Design Patterns book...Strategy p315....read through the mumbo 
jumbo...OK, I got it, a big switch
statement can be hard to maintain when things get complicated, so you 
could create an interface,
many classes that each implement the interface and then each do their 
own thing rather than you doing it
all for them in a big switch.OK, that all sounds fine, but things aren't 
that complicated here. Each
switch case is quite trivial. Not worth it to get fancy here. I'll keep 
my big switch as is, and now add
Strategy to my list of Design Patterns that I think I understand :)


More information about the antlr-interest mailing list