Category Archives:

Joel: .Net Quick Tips

Posted on April 15, 2008 by Joel Potischman

Parameterized XPath Expressions in .NET

Escaping parameters in an XPath expression in .NET is hard. Quick, which of the following is right?

Beats the hell out of me. Maybe one works, but I'm guessing not, and I'd assume a weird search term like Hello >:-< "How're you?" would blow me up. Fortunately, I found the wonderful Mvp.Xml .NET library, which will handle the tough work of escaping for me by letting me parameterize my XPath expressions, thereby protecting me from blowups and XPath injection attacks, like a search for '|@superuser='true. I can rewrite that search as follows:

How nice is that?

| Comments (0) | Technorati Tags :

Posted on April 1, 2008 by Joel Potischman

Exception-Based Programming : A Primer

One of the hallmarks of modern programming languages is structured exception handling. Put simply, exception handling is a way for programs to handle "exceptions" to expected behavior. An error occurs, and it rockets up the call stack until code that knows what to do with it "catches" it. If it's left uncaught, the program shows a big ugly error message to the user and exits. This reduces cross-cutting concerns by allowing application logic to separate cleanly from exception-handling logic.

Continue reading "Exception-Based Programming : A Primer" »

| Comments (1) | Technorati Tags :