C# Expression Evaluators
Warning: this is not the usual code sample ready to be cut and pasted in your homework due for tomorrow.
OTOH, if you are one of those guys that just have to understand why and how you can implement an expression evaluator in C#, then boy has Chuck Jazdzewski some interesting information for you. Chuck likes to propose interesting problems/challenges (often useless yet fascinating) and then discuss at detail various approaches to the problem, in the case of expression evaluators, Chuck offers us four alternatives:
- The classic procedural solution (รก la plain old Visual Basic)
- The object oriented solution (at the best 199x Smalltalk/Java style)
- The visitor pattern solution (for the guys one stair above average Java or C# programmers)
- The layered solution using partial classes (for the neoteric programmers using C# 2.0 or VB.NET 2005)
As I said, don't expect a complete solution ready to be run but some pseudo-code and an interesting discussion of pros and cons. It may not help you with tomorrow's homework but it sure will help you impress the geek gal on the next cubicle.