My favorite alternative to JavaScript’s switch statement
JavaScript By Dave Ward. Posted May 23, 2013One of my least favorite parts of nearly every programming language I’ve spent much time with has been the ubiquitous switch statement. Though it does serve a useful purpose in some compiled languages, I think switch is a clunky eyesore in most code. Its structure is prone to taking root and only growing larger and more cumbersome over time.
If you’re coming to JavaScript from a background in procedural languages like C#, Java, or PHP, it’s natural to reach for the same tools, like switch, that you’re accustomed to using in those languages. However, JavaScript’s flexible object literal syntax and first-class functions offer alternatives to switch that I believe are cleaner, more extensible, and more maintainable.
So, in this post I want to show you a few ways that you can refactor a JavaScript switch statement to use this alternate technique, and improve its extensibility and maintainability in the process.
Click here to read the rest of this post »

ASP.NET Web API has been one of my favorite recent additions to ASP.NET. Whether you prefer a RESTful approach or something more RPC-oriented,
Each year, I get a little closer to not making this post before the year is over, much less on the actual anniversary of when I started posting (12/21). That’s mainly because it seems more like a “me” post instead of something that you might actually find interesting or useful and that’s not really what this site is supposed to be about. However, every time I mention skipping it, the feedback is in favor of making the post. So, here it is (and I’ll try to do better next year).



