<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>Web</title><link>http://www.agileprogrammer.com/dotnetguy/category/122.aspx</link><description>Web</description><managingEditor>Brad Wilson</managingEditor><dc:language>en-US</dc:language><generator>.Text Version 0.95.2005.109</generator><item><dc:creator>Brad Wilson</dc:creator><title>What's Right About Lambdas and LINQ</title><link>http://www.agileprogrammer.com/dotnetguy/archive/2007/04/21/22624.aspx</link><pubDate>Sat, 21 Apr 2007 07:55:00 GMT</pubDate><guid>http://www.agileprogrammer.com/dotnetguy/archive/2007/04/21/22624.aspx</guid><description>&lt;p&gt;Two features coming in C# 3.0 are pretty exciting, even though I may have initially (incorrectly) dismissed them a gimmicky.&lt;/p&gt; &lt;p&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2007/04/08/new-orcas-language-feature-lambda-expressions.aspx"&gt;Lambda Expressions&lt;/a&gt; are nice because they are syntactically simpler anonymous delegates, and hands down, anonymous delegates were the best feature of C# 2.0. Generics might've saved us some casts, but anonymous delegates saved us from making whole methods or types, and because they're closures, they eliminate the need for nasty things like passing opaque objects through callbacks. Lambda Expressions make anonymous delegates compact and readable. This was a no-brainer for me.&lt;/p&gt; &lt;p&gt;I was less sure about LINQ. With LINQ Expressions, you can write vaguely SQLish code:&lt;/p&gt;&lt;pre&gt;IEnumerable&amp;lt;Person&amp;gt; results = from p in people
                              where p.LastName.StartsWith("G")
                              orderby p.FirstName
                              select p;&lt;/pre&gt;
&lt;p&gt;or the more explicit:&lt;/p&gt;&lt;pre&gt;IEnumerable&amp;lt;Person&amp;gt; results = people.Where(p=&amp;gt;p.LastName.StartsWith("G"))
                                    .OrderBy(p=&amp;gt;p.FirstName);&lt;/pre&gt;
&lt;p&gt;There are&amp;nbsp;obvious reasons to like this: no chance for SQL injection bugs, don't need to switch your brain from C# mode to SQL mode and back, hiding the simpler differences between database engines, etc.&lt;/p&gt;
&lt;p&gt;There's a bigger bang for the buck hiding here, though: it's very likely to make database refactoring dramatically simpler. I like being able to think about all of my database operations in terms of my native development language. Rails does this today with Migrations, and C# 3.0 could benefit from a similar system.&lt;/p&gt;
&lt;p&gt;It will really hit the 85% problem well, and then we can build intelligent database refactoring systems that understand how to build migrations as well as modify the query code, without ever having to touch SQL in the process. We can also use static analysis tools to find simple performance issues (missing indices on things that are used in where clauses, for example). The wealth of value that opens up here is almost staggering.&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="0767317B-992E-4b12-91E0-4F059A8CECA8:2185aacc-5491-4174-9c0f-c7a87b0e18ad" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;i&gt;Technorati tags: &lt;a href="http://technorati.com/tags/C#%203.0" rel="tag"&gt;C# 3.0&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Lambda%20Expression" rel="tag"&gt;Lambda Expression&lt;/a&gt;, &lt;a href="http://technorati.com/tags/LINQ" rel="tag"&gt;LINQ&lt;/a&gt;, &lt;a href="http://technorati.com/tags/refactoring" rel="tag"&gt;refactoring&lt;/a&gt;, &lt;a href="http://technorati.com/tags/agile" rel="tag"&gt;agile&lt;/a&gt;, &lt;a href="http://technorati.com/tags/database" rel="tag"&gt;database&lt;/a&gt;, &lt;a href="http://technorati.com/tags/SQL" rel="tag"&gt;SQL&lt;/a&gt;&lt;/i&gt;&lt;/div&gt;&lt;img src ="http://www.agileprogrammer.com/dotnetguy/aggbug/22624.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Brad Wilson</dc:creator><title>Web Developer's Handbook</title><link>http://www.agileprogrammer.com/dotnetguy/archive/2007/01/19/22072.aspx</link><pubDate>Fri, 19 Jan 2007 08:20:00 GMT</pubDate><guid>http://www.agileprogrammer.com/dotnetguy/archive/2007/01/19/22072.aspx</guid><description>&lt;p&gt;Someone has cultivated an impressive number of &lt;a href="http://www.css-techniques.com/"&gt;links for web developers&lt;/a&gt;. Worth bookmarking for the CSSified among us. [found via &lt;a href="http://chris.pirillo.com/"&gt;Pirillo&lt;/a&gt;'s daily link dump... wait, what do you mean I can't link to an e-mail message!?]&lt;/p&gt;&lt;img src ="http://www.agileprogrammer.com/dotnetguy/aggbug/22072.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Brad Wilson</dc:creator><title>JSON vs. XML</title><link>http://www.agileprogrammer.com/dotnetguy/archive/2007/01/04/21965.aspx</link><pubDate>Thu, 04 Jan 2007 08:34:00 GMT</pubDate><guid>http://www.agileprogrammer.com/dotnetguy/archive/2007/01/04/21965.aspx</guid><description>Fellow 'softie Dare Obasanjo has a couple great articles on JSON vs. XML: &lt;a href="http://www.25hoursaday.com/weblog/PermaLink.aspx?guid=060ca7c3-b03f-41aa-937b-c8cba5b7f986"&gt;Browser Security Model&lt;/a&gt; and &lt;a href="http://www.25hoursaday.com/weblog/PermaLink.aspx?guid=39842a17-781a-45c8-ade5-58286909226b"&gt;Browser Programming Models&lt;/a&gt;. &lt;p&gt;Dare used to work on the XML team here at Microsoft, and is someone I consider more than well enough versed to make the comparison. His conclusions are interesting, because he approaches the problem from a different angle than most (who compare the serialization formats). Definitely very good reads.&lt;/p&gt;&lt;img src ="http://www.agileprogrammer.com/dotnetguy/aggbug/21965.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Brad Wilson</dc:creator><title>Writing Your Own Front Controller for Rails</title><link>http://www.agileprogrammer.com/dotnetguy/archive/2006/07/09/16917.aspx</link><pubDate>Sun, 09 Jul 2006 17:51:00 GMT</pubDate><guid>http://www.agileprogrammer.com/dotnetguy/archive/2006/07/09/16917.aspx</guid><description>&lt;p&gt;I've been spending the weekend catching up with Rails, and one of the projects I'm working on necessitated that I write my own &lt;a href="http://www.martinfowler.com/eaaCatalog/frontController.html"&gt;front controller&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Of course, most people use the Routes system that's built into Rails, which is good enough for the vast majority of applications. However, my URLs are data driven, so maintaining the routes file (and restarting the Rails server) every time I needed to modify the URL space wasn't going to work for me.&lt;/p&gt;
&lt;p&gt;I spent the majority of my time finding the right thing to override to get into the request chain. The simplest way seemed to be to override the recognize method in ActionController::Routing::RouteSet, like this: (code from /config/environment.rb)&lt;/p&gt;
&lt;pre&gt;module ActionController
  module Routing
    class RouteSet
      def recognize(request)
        FrontController.new
      end
    end
  end
end&lt;/pre&gt;
&lt;p&gt;You can delete all the code from /config/routes.rb, since this avoids the entire route system and forwards all requests to FrontController.&lt;/p&gt;
&lt;p&gt;Then I defined FrontController like so:&lt;/p&gt;
&lt;pre&gt;class FrontController &lt; ApplicationController
  def process(request, response, method = :perform_action, *arguments)
    super(request, response, :index)
  end

  def index
    @req_host = request.env["HTTP_HOST"]
    @req_url = request.env["PATH_INFO"]

    find_controller.constantize.new.process(request, response)
  rescue NameError
    render :file =&gt; "public/404.html"
  end

  def find_controller
    # write your code to crack your URL and figure out your controller class
    # return the controller class name as a string
    return "MySpecialController"
  end
end&lt;/pre&gt;
&lt;p&gt;The find_controller method is where you'll do whatever work you need to crack the URL and figure out what controller you're going to use. The controllers you chain to are defined just like any traditional Rails controller is, including support for rendering views. The call to "constantize" turns the string into an instance of the Class object for the controller class; a new instance of the controller is made, and we call process to chain up the results.&lt;/p&gt;
&lt;p&gt;Any modifications you make to request and response will be passed along to the new controller, so you should take the opportunity inside of find_controller to set params[:action] to the name of the action method that you'd like dispatched on your controller class. In my case, I was parsing a whole variety of potential URL spaces (hostnames and paths) to a variety of controller types. The type of the controller depends partially on the prefix of the URL space, and the action may or may not be derived from other portions of the URL.&lt;/p&gt;
&lt;p&gt;Obviously, this system has some down-sides. You have to do the URL cracking yourself, and the handy redirect_to() calls with the hash parameters can't reconstruct your URLs for you. However, in my case, it would have been simply impossible to set up static routes to cover everything, so I'm okay with this limitation. I'm using a new base class for my controllers which gives them alternatives to things like redirect_to and link_to.&lt;/p&gt;&lt;img src ="http://www.agileprogrammer.com/dotnetguy/aggbug/16917.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Brad Wilson</dc:creator><title>Adding Templates to ASP.NET 2.0 User Controls</title><link>http://www.agileprogrammer.com/dotnetguy/archive/2006/06/04/15677.aspx</link><pubDate>Sun, 04 Jun 2006 12:10:00 GMT</pubDate><guid>http://www.agileprogrammer.com/dotnetguy/archive/2006/06/04/15677.aspx</guid><description>&lt;p&gt;Robert Seder has a nice description of &lt;a href="http://90statehouse.com/forums/blogs/robertseder/archive/2006/06/04/201.aspx"&gt;adding template functionalty to ASP.NET 2.0 user controls&lt;/a&gt;. Found via &lt;a href="http://weblogs.asp.net/scottgu/archive/2006/06/04/Supporting-Templates-with-ASP.NET-User-Controls.aspx"&gt;ScottGu&lt;/a&gt;.&lt;/p&gt;&lt;img src ="http://www.agileprogrammer.com/dotnetguy/aggbug/15677.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Brad Wilson</dc:creator><title>Web Application Project Released</title><link>http://www.agileprogrammer.com/dotnetguy/archive/2006/05/09/14481.aspx</link><pubDate>Tue, 09 May 2006 09:24:00 GMT</pubDate><guid>http://www.agileprogrammer.com/dotnetguy/archive/2006/05/09/14481.aspx</guid><description>&lt;p&gt;The Web Application Project is an add-on to Visual Studio which returns the VS2003 style of web project -- with an explicit project file and free-form directory structure --&amp;nbsp;while retaining the benefits of VS2005, like the built-in development web server. In my mind, enterprise-level ASP.NET development can reap great benefits from this.&lt;/p&gt;
&lt;p&gt;You can download it &lt;a href="http://msdn.microsoft.com/asp.net/reference/infrastructure/wap/default.aspx"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;img src ="http://www.agileprogrammer.com/dotnetguy/aggbug/14481.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Brad Wilson</dc:creator><title>Mix06 Sessions Online!</title><link>http://www.agileprogrammer.com/dotnetguy/archive/2006/05/04/14283.aspx</link><pubDate>Thu, 04 May 2006 07:56:00 GMT</pubDate><guid>http://www.agileprogrammer.com/dotnetguy/archive/2006/05/04/14283.aspx</guid><description>&lt;P&gt;&lt;A href="http://sessions.mix06.com/"&gt;All the sessions from Mix06 are online and available&lt;/A&gt;, with no registration required. Very cool!&lt;/P&gt;&lt;img src ="http://www.agileprogrammer.com/dotnetguy/aggbug/14283.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Brad Wilson</dc:creator><title>Watching the World Shift</title><link>http://www.agileprogrammer.com/dotnetguy/archive/2006/03/12/12239.aspx</link><pubDate>Sun, 12 Mar 2006 23:33:00 GMT</pubDate><guid>http://www.agileprogrammer.com/dotnetguy/archive/2006/03/12/12239.aspx</guid><description>&lt;P&gt;In &lt;A href="http://lesscode.org/2006/03/12/someone-tell-gosling/"&gt;Gosling Didn't Get the Memo&lt;/A&gt;, Ryan Tomayko writes:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;I believe that a majority of people in IT now consider dynamic languages like Perl, Ruby, Python, and PHP to be very much capable of sitting at the table with Java and .NET for a wide range of common technical problems. Similarly, straight-forward systems like REST, Microformats, and Atom are generally considered legitimate alternatives to the vendor/analyst/press peddled technologies like WS-* for a wide range of integration issues.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;This is a very interesting read for people who live solely on the "compiled" side of the fence.&lt;img src ="http://www.agileprogrammer.com/dotnetguy/aggbug/12239.aspx" width = "1" height = "1" /&gt;</description></item></channel></rss>