<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:at="http://www.sixapart.com/ns/at"
    xmlns:icbm="http://postneo.com/icbm"
    xmlns:rvw="http://purl.org/NET/RVW/0.2/"
    xmlns:media="http://search.yahoo.com/mrss">
    <channel>
        <title>Renaissance Programmer</title>
        <link>http://jcoehoorn.vox.com/library/posts/page/1/</link>
        <description></description>
        <language>en</language>
        <generator>Vox</generator>
        <lastBuildDate>Mon, 21 Jul 2008 09:25:14 -0700</lastBuildDate>
        <copyright>Copyright 2008</copyright>
        <docs>http://blogs.law.harvard.edu/tech/rss</docs>  
 
        <item>
            <title>Idea for Simple Multi-threaded Software</title>
            <link>http://jcoehoorn.vox.com/library/post/idea-for-simple-multi-threaded-software.html?_c=feed-rss-full</link>   
            <author>nobody@vox.com(jcoehoorn)</author>
            <comments>http://jcoehoorn.vox.com/library/post/idea-for-simple-multi-threaded-software.html?_c=feed-rss-full</comments>
            <guid isPermaLink="true">http://jcoehoorn.vox.com/library/post/idea-for-simple-multi-threaded-software.html?_c=feed-rss-full</guid> 
            <pubDate>Mon, 21 Jul 2008 09:25:14 -0700</pubDate>         
            
            <description>    &lt;p&gt;As multi-core CPUs become more and more common, the ability to write quality software that takes advantage of them will become more important.&amp;#160; The tools currently available are not adequate to this task.&amp;#160; We are seeing a few things emerge to help solve the problem.&amp;#160; One good example is the shift back to web applications hosted on a server.&amp;#160; Web applications automatically run in parallel; each request can get it&amp;#39;s own thread.&amp;#160; However, there&amp;#39;s still a shortage of simple, effective techiques for building parallel software on the desktop.&lt;/p&gt;&lt;p&gt;I had an idea of one place that where it would be very easy to build a parallel software approach into the programming language, so that developers can take advantage of a multi-core cpu in certain situations without having to do extra work.&amp;#160; This idea is obvious enough that it probably isn&amp;#39;t new to me, but I don&amp;#39;t think I&amp;#39;ve read about it anywhere else and so I wanted to write it out here.&lt;/p&gt;&lt;p&gt;What I want to do is updated the standard &amp;quot;foreach&amp;quot; loop that&amp;#39;s included in most modern programming languages.&amp;#160; .Net, java, PHP, Python, and more all have this simple loop.&amp;#160; In a for each loop, you specify an operation to be performed on every item in a collection of items.&amp;#160; Current implementations of this loop always run in serial.&amp;#160; Process one item, and when that one is finished get the next and process it.&amp;#160; However, much of the time this could be done in parallel.&amp;#160; My idea is that you could bake this concept into a programming language by making a simple change to your loop declaration.&amp;#160; For example, take this simple C# loop declaration.&amp;#160; Instead of this:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;span style=&quot;color: #3366ff&quot;&gt;foreach &lt;/span&gt;(&lt;span style=&quot;color: #3366ff&quot;&gt;object &lt;/span&gt;Item &lt;span style=&quot;color: #3366ff&quot;&gt;in &lt;/span&gt;MyCollection)&lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;Do this:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;span style=&quot;color: #3366ff&quot;&gt;forevery &lt;/span&gt;(&lt;span style=&quot;color: #3366ff&quot;&gt;object &lt;/span&gt;Item &lt;span style=&quot;color: #3366ff&quot;&gt;in &lt;/span&gt;MyCollection)&lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;Change just one key word and the compiler knows it can use create separate threads for the contents of the loop.&amp;#160; &lt;span style=&quot;color: #3366ff&quot;&gt;&lt;/p&gt;&lt;/span&gt;&lt;p&gt;Of course, there are situations where these loops should not be run in parallel.&amp;#160; Maybe you need to break early.&amp;#160; Or maybe you&amp;#39;re building a count as you go.&amp;#160; But this should be relatively easy for the programmer to determine, and they can always use the old behavior when needed.&lt;/p&gt;&lt;p&gt;Are there any languages out there that already implement this concept?&lt;br /&gt;&lt;/p&gt;    &lt;p style=&quot;clear:both;&quot;&gt; 
    &lt;a href=&quot;http://jcoehoorn.vox.com/library/post/idea-for-simple-multi-threaded-software.html?_c=feed-rss-full#comments&quot;&gt;Read and post comments&lt;/a&gt;   |   
    &lt;a href=&quot;http://www.vox.com/share/6a00c22525ad91604a00fad69bbb680005?_c=feed-rss-full&quot;&gt;Send to a friend&lt;/a&gt; 
&lt;/p&gt;
 
            </description>   
        </item> 
 
        <item>
            <title>VB.Net vs C#, Round 2: Partial Namespaces</title>
            <link>http://jcoehoorn.vox.com/library/post/vbnet-vs-c-round-2-partial-namespaces.html?_c=feed-rss-full</link>   
            <author>nobody@vox.com(jcoehoorn)</author>
            <comments>http://jcoehoorn.vox.com/library/post/vbnet-vs-c-round-2-partial-namespaces.html?_c=feed-rss-full</comments>
            <guid isPermaLink="true">http://jcoehoorn.vox.com/library/post/vbnet-vs-c-round-2-partial-namespaces.html?_c=feed-rss-full</guid> 
            <pubDate>Thu, 17 Jul 2008 10:31:25 -0700</pubDate>         
            
            <description>    &lt;p&gt;I&amp;#39;ve &lt;a href=&quot;http://jcoehoorn.vox.com/library/post/why-i-like-vbnet-over-c.html&quot;&gt;talked about this before&lt;/a&gt;, and I don&amp;#39;t want to go over the same issues a second time.&amp;#160; However, I recently had a project where I finally spent a few weeks in C#, with no VB work at all.&amp;#160; At last, I had a chance to develop a deeper familiarity with C#.&amp;#160; Maybe I would learn something new.&amp;#160; &lt;/p&gt;&lt;p&gt;The result?&amp;#160; C# moves closer to VB.Net in my estimation, but doesn&amp;#39;t quite pass it.&amp;#160; All of the short-comings when compared to VB.Net still exist in my mind, but now I&amp;#39;ve had the chance to get a feel for what C# does about them.&amp;#160; I can&amp;#39;t put my finger on it, but there are little things here and there in C# that make up for a lot of what I complained about before.&amp;#160; For example, I still prefer seeing &amp;quot;End If&amp;quot;, &amp;quot;End Sub&amp;quot;, &amp;quot;End Class&amp;quot;, etc to the more ambiguous &amp;quot;}&amp;quot;.&amp;#160; But now that I&amp;#39;ve used C# more it&amp;#39;s not as big a deal.&amp;#160; I like the VB way, but I&amp;#39;m not as handicapped by C# as I was.&amp;#160; The gap is still there, but it&amp;#39;s not as wide.&lt;/p&gt;&lt;p&gt;The experience did bring one new shorting coming in C# that I didn&amp;#39;t write about before.&amp;#160; VB.Net supports partial namespaces; C# does not.&amp;#160; Let me explain.&amp;#160; Imagine you want to read from a file.&amp;#160; In .Net, that means using the System.IO namespace.&amp;#160; With Visual Basic, System is imported by default and child namespaces are automatically resolved.&amp;#160; So, for example, to see if a file exists I can just say something like this:&lt;br /&gt;&lt;blockquote&gt;&lt;p&gt;&lt;span style=&quot;color: #3366ff&quot;&gt;If &lt;/span&gt;IO.File.Exists(&lt;span style=&quot;color: #144692&quot;&gt;&amp;quot;foo.bar&amp;quot;&lt;/span&gt;) &lt;span style=&quot;color: #3366ff&quot;&gt;Then &lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt;That won&amp;#39;t work in C#.&amp;#160; You have to either type out System.IO.File or add a using directive for System.IO at the top of the file.&amp;#160; Now the IO namespace this isn&amp;#39;t a big deal.&amp;#160; You&amp;#39;re probably going to use the classes from the namespace a dozen times if you use them once, or it&amp;#39;s not a lot to type otherwise.&amp;#160;&amp;#160; It does pollute your intellisense namespace though, and it starts to become annoying when you also need StringBuilder and have to import System.Text but aren&amp;#39;t using anything else from that namespace.&amp;#160; Or maybe you need a single Dataset, but nothing else from System.Data.&amp;#160; You can quickly accumulate several using directives that only exist to support one class declaration.&amp;#160; The point is that the class library heirarchy in .Net is rather flat, and there are a lot of little things you might want that in C# that all require a using directive where VB.Net does not.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;So C# doesn&amp;#39;t let you use a partial namespace in a declaration.&amp;#160; Big deal.&amp;#160; Well, this example only illustrates the least of my complaints.&amp;#160; The worst things about what I&amp;#39;ve shown so far are that it leads to a polluted intellisense prompt and that it breaks your flow to have to jump to the top of the page to add the declaration and then jumb back versus simply typing a shorter name.&amp;#160; If this was all there was to it I would just keep my mouth shut and deal with it.&amp;#160; But there are other, more important manifestations.&amp;#160; I&amp;#39;ll give two examples.&lt;/p&gt;&lt;p&gt;Say you&amp;#39;re working on a project that involves a lot of XML.&amp;#160; You&amp;#39;ll probably import the System.Xml namespace.&amp;#160; In C# you may also need to import one or more of System.Xml.Schema, System.Xml.XPath, System.Xml.Serialization, or System.Xml.Xsl.&amp;#160; And now you&amp;#39;re using a whole bunch of different classes with no reference in the code for which specific namespace each class came from.&amp;#160; In VB.Net you can just preface the class names of classes not directly in the Xml namespace with only the missing child namespace.&amp;#160; For example, if I choose not to import System.Xml.Schema but already have System.Xml I can still just say &amp;quot;Schema.XmlSchema&amp;quot; instead of &amp;quot;System.Xml.Schema.XmlSchema&amp;quot;.&amp;#160; &lt;span style=&quot;color: #144692&quot;&gt;&lt;/p&gt;&lt;/span&gt;&lt;p&gt;That sounds a lot like the same complaint I had earlier, and it usually ends up requiring a little more typing than importing all the namespaces once.&amp;#160; What&amp;#39;s new, though, is that in my opinion this has the potential tomake the code easier to understand.&amp;#160; The specific example of &amp;quot;Schema.XmlSchema&amp;quot; is pretty redundant, but there are plenty of cases where having one level of the namespace with the class would add clarity to the declaration.&amp;#160; This is especially true for junior developers who may not be totally familiar with the framework.&amp;#160; Used correctly, it can provide just a little bit of important context for each of your declarations.&lt;/p&gt;&lt;p&gt;Now for the next example.&amp;#160; After all, the Xml namespace is pretty well understood.&amp;#160; Also, my XML example wasn&amp;#39;t very good; what do we need the extra context for?&amp;#160; Fair enough.&amp;#160; Let&amp;#39;s look at something even more relevant.&amp;#160; What if you&amp;#39;re working on a project where you want to use a third party library?&amp;#160; In this case, being able to see a small amount of context for each class may have a little more value.&amp;#160; And what if you&amp;#39;ve never used this library before?&amp;#160; &lt;/p&gt;&lt;p&gt;The &lt;a href=&quot;http://sharpdevelop.net/OpenSource/SharpZipLib/&quot;&gt;SharpZipLib&lt;/a&gt; comes to mind as a reasonable example.&amp;#160; Imagine your project involved using the library to untar some files.&amp;#160; In C# you would import ICSharpCode.SharpZipLib.Tar and then type class names as usuall.&amp;#160; However, there is no help from the IDE in finding out what those classes are without re-typing the entire namespace every time.&amp;#160; This shows one final reason why partial namespaces are useful.&amp;#160; In VB.Net you just import ICSharpCode.SharpZipLib.&amp;#160; Now, if you only type &amp;quot;Tar.&amp;quot; you get an intellisense list of members of that namespace as soon as you hit the period key.&amp;#160; For this reason, I find VB.Net is much easier to work with when learning the ins and outs of a new library.&lt;/p&gt;&lt;p&gt;In summary, I really like VB.Net&amp;#39;s ability to use partial namespaces in declarations.&amp;#160; There&amp;#39;s probably a more official name for the feature, but I don&amp;#39;t know
it.&amp;#160; It might even be something you can just turn on as an option for a project in
C#, in which case I hope someone will tell me where to find that option.&amp;#160; I think the feature promotes code that is more readable, doesn&amp;#39;t break the flow of the programmer as often, keeps your intellisense namespace clearer, and aids in learning new libraries.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;    &lt;p style=&quot;clear:both;&quot;&gt; 
    &lt;a href=&quot;http://jcoehoorn.vox.com/library/post/vbnet-vs-c-round-2-partial-namespaces.html?_c=feed-rss-full#comments&quot;&gt;Read and post comments&lt;/a&gt;   |   
    &lt;a href=&quot;http://www.vox.com/share/6a00c22525ad91604a00fae8cce237000b?_c=feed-rss-full&quot;&gt;Send to a friend&lt;/a&gt; 
&lt;/p&gt;
 
            </description>   
        </item> 
 
        <item>
            <title>Make your Code as Useful as Possible</title>
            <link>http://jcoehoorn.vox.com/library/post/make-your-code-as-useful-as-possible.html?_c=feed-rss-full</link>   
            <author>nobody@vox.com(jcoehoorn)</author>
            <comments>http://jcoehoorn.vox.com/library/post/make-your-code-as-useful-as-possible.html?_c=feed-rss-full</comments>
            <guid isPermaLink="true">http://jcoehoorn.vox.com/library/post/make-your-code-as-useful-as-possible.html?_c=feed-rss-full</guid> 
            <pubDate>Wed, 16 Jul 2008 10:35:23 -0700</pubDate>         
            
            <description>    &lt;p&gt;I don&amp;#39;t know how many times I&amp;#39;ve seen code similar to the following on programming help forums:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;span style=&quot;color: #3366ff&quot;&gt;Function &lt;/span&gt;MyMethod(&lt;span style=&quot;color: #3366ff&quot;&gt;ByVal &lt;/span&gt;InputParameter() &lt;span style=&quot;color: #3366ff&quot;&gt;As String&lt;/span&gt;) As &lt;span style=&quot;color: #3366ff&quot;&gt;String&lt;/span&gt;()&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style=&quot;color: #339933&quot;&gt;&amp;#39;Do Stuff here that returns a different string array&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #3366ff&quot;&gt;End Function&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;That&amp;#39;s okay.&amp;#160; We can make that work just fine.&amp;#160; I mean, it could be worse; they could have used an &lt;em&gt;ArrayList&lt;/em&gt;.&amp;#160; But we can do better, too.&amp;#160; Now look at this code:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;span style=&quot;color: #3366ff&quot;&gt;Function &lt;/span&gt;MyNewMethod(&lt;span style=&quot;color: #3366ff&quot;&gt;ByVal &lt;/span&gt;InputParameter &lt;span style=&quot;color: #3366ff&quot;&gt;As &lt;/span&gt;IEnumerable(&lt;span style=&quot;color: #3366ff&quot;&gt;Of&lt;/span&gt; &lt;span style=&quot;color: #3366ff&quot;&gt;String&lt;/span&gt;)) &lt;span style=&quot;color: #3366ff&quot;&gt;As &lt;/span&gt;StringCollection&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style=&quot;color: #339933&quot;&gt; &amp;#39;Do stuff here that returns the string collection&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #3366ff&quot;&gt;End Function&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;This code is a drop in replacement for the code above.&amp;#160; By that I mean that anywhere you call the first method, you could replace it with the 2nd method and your code will still work.&amp;#160; You don&amp;#39;t have to change anything else except the type of the variable that accepts the result.&amp;#160; So if it works the same, why change?&amp;#160; I mean, it takes a little more thought to read it and therefore you could argue it takes more to maintain.&amp;#160; What do you gain?&amp;#160; The answer is that you&amp;#39;ve just made the function more useful and flexible.&lt;/p&gt;&lt;p&gt;Let&amp;#39;s start with the InputParameter.&amp;#160; Perhaps right now you have always have a string array when you call it.&amp;#160; But what if later you start working with something like an ArrayList or the generic List(Of String)?&amp;#160; Those will both work with that method right now, with no other changes.&amp;#160; You can even put Xml or datatables through there with a little work.&amp;#160; IEnumerable(Of String) will accept anything that can give you a string in a For Each loop.&amp;#160; So just by changing the type I&amp;#39;ve instantly made the code more powerful.&lt;/p&gt;&lt;p&gt;Now for the return type.&amp;#160; I could have used IEnumerable(Of String) here as well.&amp;#160; However, in this case that would actually limit the capabilities of the function.&amp;#160; You&amp;#39;d lose the ability to look at values by index.&amp;#160; What I want to do is expand the capabilities of the function.&amp;#160; String() already implies IEnumerable(Of String).&amp;#160; However, by moving from the&amp;#160; array up to a StringCollection I not only keep that ability but gain the ability to easily add or remove items from the collection.&amp;#160; I also get some bonuses like the nice .Contains() and .IndexOf() methods.&amp;#160; So again, I&amp;#39;ve expanded what the function can do, and therefore made it more valuable.&amp;#160; &lt;/p&gt;&lt;p&gt;For example, you might now be able to use it somewhere that before would have required a separate (but very similar) function.&amp;#160; Or the switch to the new function might save you having to write a for each loop on the return value because of additional capabilities in the collection like the .Contains() method.&amp;#160; It will enable you to get the same work done in less code.&lt;/p&gt;&lt;p&gt;One other point is that the new version should perform about the same as the old one. There might be a very small loss, but any difference is likely to be minor relative to other considerations in your code.&amp;#160; Certainly falls under the heading of &amp;quot;premature optimization.&amp;quot;&lt;/p&gt;&lt;p&gt;In general, we can think of IEnumerable(Of String) as a wider type, and StringCollection as a more powerful type.&amp;#160; A good rule of thumb is to accept a wider type for input and return a more powerful type for output.&amp;#160; In this way you will make your code more useful, and in the long run that&amp;#39;s probably a good thing.&lt;/p&gt;     &lt;p style=&quot;clear:both;&quot;&gt; 
    &lt;a href=&quot;http://jcoehoorn.vox.com/library/post/make-your-code-as-useful-as-possible.html?_c=feed-rss-full#comments&quot;&gt;Read and post comments&lt;/a&gt;   |   
    &lt;a href=&quot;http://www.vox.com/share/6a00c22525ad91604a00fad69a3d7d0005?_c=feed-rss-full&quot;&gt;Send to a friend&lt;/a&gt; 
&lt;/p&gt;
 
            </description>   
        </item> 
 
        <item>
            <title>The Power of Declarative Code in ASP.Net</title>
            <link>http://jcoehoorn.vox.com/library/post/the-power-of-declarative-code-in-aspnet.html?_c=feed-rss-full</link>   
            <author>nobody@vox.com(jcoehoorn)</author>
            <comments>http://jcoehoorn.vox.com/library/post/the-power-of-declarative-code-in-aspnet.html?_c=feed-rss-full</comments>
            <guid isPermaLink="true">http://jcoehoorn.vox.com/library/post/the-power-of-declarative-code-in-aspnet.html?_c=feed-rss-full</guid> 
            <pubDate>Fri, 11 Jul 2008 08:55:55 -0700</pubDate>         
            
            <description>    &lt;p&gt;ASP.Net is often mistaken for a simple update to Classic ASP.&amp;#160; Just take ASP, throw in some .Net classes, and you&amp;#39;re done.&amp;#160; You get a better IDE and you might get a small performance boost from using pre-compiled code, but not much else.&amp;#160; Of course, you &lt;em&gt;could &lt;/em&gt;use ASP.Net like Classic ASP.&amp;#160; If that&amp;#39;s as far as you go then I suppose everything above would be true.&amp;#160; In fact, one of the nice things about ASP.Net is it&amp;#39;s ability to work with you as your skills grow, and give at least small benefits right away.&amp;#160; But if you stop here you&amp;#39;re missing out on the best parts of the language.&lt;/p&gt;&lt;p&gt;ASP.Net allows you to be more declarative in how you lay out your page.&amp;#160; If an SQL SELECT query is the classic example of declarative code, than you can think of each server control as a little SELECT query.&amp;#160; It&amp;#39;s a way to declare what you want to the framework and let it worry about how to actually do it rather than listing out every little step.&amp;#160; The advantages of this approach are numerous: your code base is smaller, busy-work is reduced, you see pages from a higher level, you get better separation of concerns for designers and developers...&amp;#160;&amp;#160; I could go on.&amp;#160; You might be surprised to hear that there&amp;#39;s a huge potential performance benefit as well.&lt;/p&gt;&lt;p&gt;If that thought does surprise you, it shouldn&amp;#39;t.&amp;#160; After all, it&amp;#39;s what makes SQL fast.&amp;#160; Take an SQL cursor, for example.&amp;#160; A cursor is usually the slowest way to accomplish any task in a database.&amp;#160; Why?&amp;#160; Because it&amp;#39;s procedural.&amp;#160; If you can re-write the cursor to use declarative statements you will nearly always see a significant performance improvement.&amp;#160; This is because the database can now use it&amp;#39;s cache and indexes, and even execute the operation in parallel.&amp;#160; The same concept applies to a web page, and for the same reasons.&amp;#160; I don&amp;#39;t know to what extent, if any, ASP.Net applies these concepts.&amp;#160; But it should be theoretically possible. &lt;/p&gt;&lt;p&gt;First we&amp;#39;ll look at caching/indexing.&amp;#160; With declarative code the server can get a rough picture of what every instance of a page will look like.&amp;#160; It can use this picture to create and cache a pre-loaded version of the page, where all the declared controls and HTML are loaded and put in the intial state defined by the aspx code.&amp;#160; This is a huge improvement, because the amount of work left to do for each request is greatly reduced.&amp;#160; Classic ASP would have to start from the beginning for every single request and work it&amp;#39;s way through all of the page code to be sure of getting the correct result, like any other procedural code.&amp;#160; The ASP.Net environment can take a few shortcuts.&lt;/p&gt;&lt;p&gt;Now let&amp;#39;s move on to parallelism.&amp;#160; Server controls in ASP.Net ultimately boil down to plain old XML, and every XML document is a tree structure of tags.&amp;#160; The nature of XML means you have a certain amount of independence between siblings at any given level of the tree; the contents of one sibling aren&amp;#39;t really relevant to the contents of another sibling.&amp;#160; That means that each sibling can be processed in parallel.&amp;#160; In practice ASP.Net controls can have code that modifies other parts of the page, so this ability is not absolute.&amp;#160; However, it should be possible for the compiler to analyze the code and build a dependency tree for a page, and in this way get some advantage.&amp;#160; The important thing here is that less procedural code means a more straightforward dependency tree and a greater the potential for parallelism. &lt;/p&gt;&lt;p&gt;As CPUs with more cores become more and more common a built-in mechanism
to render a page in parallel will become more and more significant.&amp;#160; This is true even though a web server may already utilize multiple cores by&amp;#160; processing separate requests in parallel.&amp;#160; For example, while one node on a page waits for a request to a database to complete, rather than blocking the entire page other nodes can continue to process.&amp;#160; In this way individual requests can still be served faster.&lt;/p&gt;&lt;p&gt;I need to repeat that I have no idea if these concepts are currently implemented.&amp;#160; I suspect at moment they are not, and it&amp;#39;s a shame if that&amp;#39;s so. But the possibility and potential here is certainly interesting.&lt;/p&gt;    &lt;p style=&quot;clear:both;&quot;&gt; 
    &lt;a href=&quot;http://jcoehoorn.vox.com/library/post/the-power-of-declarative-code-in-aspnet.html?_c=feed-rss-full#comments&quot;&gt;Read and post comments&lt;/a&gt;   |   
    &lt;a href=&quot;http://www.vox.com/share/6a00c22525ad91604a00fad69997260004?_c=feed-rss-full&quot;&gt;Send to a friend&lt;/a&gt; 
&lt;/p&gt;
 
            </description>   
        </item> 
 
        <item>
            <title>SQL Injection, Part 2</title>
            <link>http://jcoehoorn.vox.com/library/post/sql-injection-part-2.html?_c=feed-rss-full</link>   
            <author>nobody@vox.com(jcoehoorn)</author>
            <comments>http://jcoehoorn.vox.com/library/post/sql-injection-part-2.html?_c=feed-rss-full</comments>
            <guid isPermaLink="true">http://jcoehoorn.vox.com/library/post/sql-injection-part-2.html?_c=feed-rss-full</guid> 
            <pubDate>Tue, 24 Jun 2008 15:37:46 -0700</pubDate>         
            
            <description>    &lt;p&gt;I first wrote about an &lt;a href=&quot;http://jcoehoorn.vox.com/library/post/sql-injection.html&quot;&gt;SQL Injection&lt;/a&gt; attack way back in April.&amp;#160; It died down for a while, but that attack is still going on.&amp;#160; It broadened in scope to even hit some php and ASP.Net sites, and this week I&amp;#39;ve noticed several new requests for assistance.&amp;#160; If you&amp;#39;re wondering how your site would fare, you should check out &lt;a href=&quot;http://news.cnet.com/8301-10789_3-9976521-57.html?part=rss&amp;amp;subj=news&amp;amp;tag=2547-1_3-0-5&quot;&gt;this article&lt;/a&gt;.&amp;#160; &lt;em&gt;Here are the steps to take if you need to fix the issue&lt;/em&gt;:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;strong&gt;Take down the site.&lt;/strong&gt;&amp;#160; As it stands now, the site is actively serving malware to it&amp;#39;s users.&amp;#160; This is not a situation you want to be in.&amp;#160; You can put up a temporary page to tell the users what is happening, but you should not allow the&amp;#160; site to continue operating until it&amp;#39;s fixed.&lt;/li&gt;&lt;li&gt;Fix the vulnerabilities that allowed the breach in the first place.&amp;#160; The nature of the attack is that the site will be infected again inside of a week unless the vulnerabilities are closed.&amp;#160; It could be as simple as replacing a single apostrophe with two apostrophes on a few form fields or it could be much more complicated, but it must be done.&amp;#160; The article I linked to above has some tools that can help.&lt;/li&gt;&lt;li&gt;Fix the database.&amp;#160; Now we can finally begin to undo the damage.&amp;#160; You have a couple options here, including restoring from backup, though that may not be necessary.&amp;#160; Instead, I modified the code used for the attack to help with the cure.&amp;#160; If this seems cryptic it&amp;#39;s because I only changed what was necessary to make it work.&amp;#160; &lt;em&gt;Note that you should not run this code if the database contains valid instances of the text &amp;quot;&amp;lt;script&amp;quot; anywhere:&lt;/em&gt;&lt;/li&gt;&lt;/ol&gt;&lt;blockquote&gt;&lt;p&gt;&lt;span style=&quot;color: #666666&quot;&gt;DECLARE @T varchar(255),@C varchar(255) &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #666666&quot;&gt;DECLARE Table_Cursor CURSOR FOR select a.name,b.name from sysobjects a,syscolumns b where a.id=b.id and a.xtype=&amp;#39;u&amp;#39; and (b.xtype=99 or b.xtype=35 or b.xtype=231 or b.xtype=167) &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #666666&quot;&gt;OPEN Table_Cursor FETCH NEXT FROM Table_Cursor INTO @T,@C &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #666666&quot;&gt;WHILE(@@FETCH_STATUS=0) BEGIN &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #666666&quot;&gt;exec(&amp;#39;update [&amp;#39;+@T+&amp;#39;] set [&amp;#39;+@C+&amp;#39;]=LEFT([&amp;#39;+@C+&amp;#39;], CHARINDEX(&amp;#39;&amp;#39;&amp;lt;script&amp;#39;&amp;#39;, [&amp;#39;+@C+&amp;#39;])-1)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #666666&quot;&gt;WHERE CHARINDEX(&amp;#39;&amp;#39;&amp;lt;script&amp;#39;&amp;#39;, [&amp;#39;+@C+&amp;#39;]) &amp;gt;0&amp;#39;)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #666666&quot;&gt;FETCH NEXT FROM Table_Cursor INTO @T,@C &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #666666&quot;&gt;END &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #666666&quot;&gt;CLOSE Table_Cursor &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #666666&quot;&gt;DEALLOCATE Table_Cursor&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;Now, finally, you can put the site back up and things should be back to normal.&lt;span style=&quot;color: #666666&quot;&gt; &lt;/p&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;p&gt;&lt;span style=&quot;color: #666666&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;    &lt;p style=&quot;clear:both;&quot;&gt; 
    &lt;a href=&quot;http://jcoehoorn.vox.com/library/post/sql-injection-part-2.html?_c=feed-rss-full#comments&quot;&gt;Read and post comments&lt;/a&gt;   |   
    &lt;a href=&quot;http://www.vox.com/share/6a00c22525ad91604a00fad694856d0004?_c=feed-rss-full&quot;&gt;Send to a friend&lt;/a&gt; 
&lt;/p&gt;
 
            </description>   
        </item> 
 
        <item>
            <title>Firefox</title>
            <link>http://jcoehoorn.vox.com/library/post/firefox.html?_c=feed-rss-full</link>   
            <author>nobody@vox.com(jcoehoorn)</author>
            <comments>http://jcoehoorn.vox.com/library/post/firefox.html?_c=feed-rss-full</comments>
            <guid isPermaLink="true">http://jcoehoorn.vox.com/library/post/firefox.html?_c=feed-rss-full</guid> 
            <pubDate>Tue, 17 Jun 2008 11:51:48 -0700</pubDate>         
            
            <description>    &lt;p&gt;Don&amp;#39;t forget to &lt;a href=&quot;http://www.getfirefox.com&quot;&gt;download the new Firefox&lt;/a&gt; today.&amp;#160; &lt;/p&gt;&lt;p&gt;... if you can, that is.&amp;#160; It seems that the folks over at Mozilla vastly underestimated the amount of traffic their world-record try would bring.&amp;#160; At least, the server isn&amp;#39;t responding at the moment, and hasn&amp;#39;t worked for me since the official start time nearly two hours ago.&lt;/p&gt;&lt;p&gt;You may still be able to get the new version using this link:&lt;br /&gt;&lt;a class=&quot;jive-link-external&quot; href=&quot;http://download.mozilla.org/?product=firefox-3.0&amp;amp;os=win&amp;amp;lang=en-US&quot; target=&quot;_newWindow&quot;&gt;http://download.mozilla.org/?product=firefox-3.0&amp;amp;os=win&amp;amp;lang=en-US&lt;/a&gt;&lt;/p&gt;&lt;p&gt;However, this link isn&amp;#39;t 100% reliable either, and I don&amp;#39;t know if it will get counted towards the record.&amp;#160; I have used to get install the new Firefox on the three systems I use, so if you can&amp;#39;t wait and the link doesn&amp;#39;t work on the first try then give it a few moments and try again.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&amp;#160; The site appears to be working again.&lt;br /&gt; &lt;/p&gt;    &lt;p style=&quot;clear:both;&quot;&gt; 
    &lt;a href=&quot;http://jcoehoorn.vox.com/library/post/firefox.html?_c=feed-rss-full#comments&quot;&gt;Read and post comments&lt;/a&gt;   |   
    &lt;a href=&quot;http://www.vox.com/share/6a00c22525ad91604a00fae8c3d337000b?_c=feed-rss-full&quot;&gt;Send to a friend&lt;/a&gt; 
&lt;/p&gt;
 
            </description>   
        </item> 
 
        <item>
            <title>Excel Column Names</title>
            <link>http://jcoehoorn.vox.com/library/post/excel-column-names.html?_c=feed-rss-full</link>   
            <author>nobody@vox.com(jcoehoorn)</author>
            <comments>http://jcoehoorn.vox.com/library/post/excel-column-names.html?_c=feed-rss-full</comments>
            <guid isPermaLink="true">http://jcoehoorn.vox.com/library/post/excel-column-names.html?_c=feed-rss-full</guid> 
            <pubDate>Thu, 12 Jun 2008 13:51:53 -0700</pubDate>         
            
            <description>    &lt;p&gt;&lt;span id=&quot;intelliTxt&quot;&gt;I ran across a request in a forum today to create an 
Excel column name from an index.&amp;#160; It sounds simple, but it&amp;#39;s harder than it 
looks.&lt;/span&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;The obvious solution here is to think about a column name 
as a base 26 number, with A-Z for digits.&amp;#160; Unfortunately,&amp;#160;it doesn&amp;#39;t quite work 
like that.&amp;#160; The &amp;#39;0&amp;#39; digit is broken.&amp;#160; For example, counting the column names 
from A you wrap around to AA after reaching Z. If this were base 10 it would be 
like counting from 1 to 9 and then getting 11 instead of 10, or counting from 0 
to 9 and then getting 00 instead of 10, depending on whether you treat A as 0 or 
1. So it&amp;#39;s tricky.&lt;/p&gt;I thought I could get around that but that it would 
take more work than it&amp;#39;s worth, so I decided to look around online. Surely there 
would be something already out there. What I found was a bunch of 
over-complicated implementations that all break somewhere on one of the 
boundaries I described.&amp;#160; Even the&amp;#160;&lt;a href=&quot;http://support.microsoft.com/kb/833402&quot;&gt;Microsft support 
example&lt;/a&gt;&amp;#160;doesn&amp;#39;t work well.&amp;#160; What a disappointment.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;So I ended up 
writing a new version after all.&amp;#160;&amp;#160;This one will scale, and it&amp;#39;s not even that 
complicated. I just had to get a little recursive:&lt;/span&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;span style=&quot;font-size: small; color: #0000ff&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;font-size: small&quot;&gt; 
ColumnName(&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff&quot;&gt;ByVal&lt;/span&gt;&lt;span style=&quot;font-size: small&quot;&gt; index 
&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;font-size: small&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff&quot;&gt;Integer&lt;/span&gt;&lt;span style=&quot;font-size: small&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;font-size: small&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff&quot;&gt;String&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Static&lt;/span&gt;&lt;span style=&quot;font-size: small&quot;&gt; chars() 
&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;font-size: small&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff&quot;&gt;Char&lt;/span&gt;&lt;span style=&quot;font-size: small&quot;&gt; = {&amp;quot;A&amp;quot;c, &amp;quot;B&amp;quot;c, &amp;quot;C&amp;quot;c, &amp;quot;D&amp;quot;c, &amp;quot;E&amp;quot;c, 
&amp;quot;F&amp;quot;c, &amp;quot;G&amp;quot;c, &amp;quot;H&amp;quot;c, &amp;quot;I&amp;quot;c, &amp;quot;J&amp;quot;c, &amp;quot;K&amp;quot;c, &amp;quot;L&amp;quot;c, &amp;quot;M&amp;quot;c, &amp;quot;N&amp;quot;c, &amp;quot;O&amp;quot;c, &amp;quot;P&amp;quot;c, &amp;quot;Q&amp;quot;c, &amp;quot;R&amp;quot;c, 
&amp;quot;S&amp;quot;c, &amp;quot;T&amp;quot;c, &amp;quot;U&amp;quot;c, &amp;quot;V&amp;quot;c, &amp;quot;W&amp;quot;c, &amp;quot;X&amp;quot;c, &amp;quot;Y&amp;quot;c, &amp;quot;Z&amp;quot;c}&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: small&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; index -= &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #800000&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;font-size: small&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #339933&quot;&gt;&amp;#39;adjust so it matches 0-indexed array rather than 1-indexed 
column&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: small; color: #0000ff&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Dim&lt;/span&gt;&lt;span style=&quot;font-size: small&quot;&gt; quotient 
&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff&quot;&gt;As&lt;/span&gt;&lt;span style=&quot;font-size: small&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff&quot;&gt;Integer&lt;/span&gt;&lt;span style=&quot;font-size: small&quot;&gt; = index \ &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #800000&quot;&gt;26&lt;/span&gt;&lt;span style=&quot;font-size: small&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #339933&quot;&gt;&amp;#39;normal / operator rounds. \ does integer division, which 
truncates&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: small&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff&quot;&gt;If&lt;/span&gt;&lt;span style=&quot;font-size: small&quot;&gt; quotient &amp;gt; 
&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #800000&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;font-size: small&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff&quot;&gt;Then&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: small&quot;&gt;&amp;#160;&amp;#160; &amp;#160;&amp;#160; &amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ColumnName = 
ColumnName(quotient) &amp;amp; chars(index &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff&quot;&gt;Mod&lt;/span&gt;&lt;span style=&quot;font-size: small&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #800000&quot;&gt;26&lt;/span&gt;&lt;span style=&quot;font-size: small&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: small; color: #0000ff&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Else&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: small; color: #0000ff&quot;&gt;&amp;#160;&amp;#160; &amp;#160;&amp;#160; &amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style=&quot;font-size: small&quot;&gt;ColumnName = chars(index &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff&quot;&gt;Mod&lt;/span&gt;&lt;span style=&quot;font-size: small&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: small; color: #800000&quot;&gt;26)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: small; color: #0000ff&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End&lt;/span&gt;&lt;span style=&quot;font-size: small&quot;&gt; 
&lt;/span&gt;&lt;span style=&quot;font-size: small; color: #0000ff&quot;&gt;If&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: small; color: #0000ff&quot;&gt;End Function&lt;/span&gt;&lt;span style=&quot;font-size: small&quot;&gt; &lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;blockquote dir=&quot;ltr&quot; style=&quot;margin-right: 0px;&quot;&gt;&lt;p&gt;&lt;span&gt;&lt;blockquote dir=&quot;ltr&quot; style=&quot;margin-right: 0px;&quot;&gt;

&lt;p&gt;&lt;span style=&quot;font-size: small&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;font-size: small&quot;&gt;
&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;span style=&quot;font-size: small&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;span style=&quot;font-size: small; color: #0000ff&quot;&gt;&lt;span style=&quot;color: #000000&quot;&gt;That still needs some basic bounds and error checking, but it works well for a quick sample.&amp;#160; It&amp;#39;s only 11 lines 
of code as is appears in my IDE (curse the vox formatter!) so it&amp;#39;s pretty easy 
to follow.&amp;#160; It should perform well too, since it would be very odd have more 
than&amp;#160;one or two recursive calls.&amp;#160; Now hopefully Google can index this page 
better than all those bad implementations I saw out there, but I&amp;#39;m not holding 
my breath.&lt;/span&gt;&lt;/span&gt;

&lt;p dir=&quot;ltr&quot; style=&quot;margin-right: 0px;&quot;&gt;&lt;span style=&quot;font-size: small; color: #0000ff&quot;&gt;&lt;/span&gt;&amp;#160;&lt;/p&gt; &lt;/p&gt;    &lt;p style=&quot;clear:both;&quot;&gt; 
    &lt;a href=&quot;http://jcoehoorn.vox.com/library/post/excel-column-names.html?_c=feed-rss-full#comments&quot;&gt;Read and post comments&lt;/a&gt;   |   
    &lt;a href=&quot;http://www.vox.com/share/6a00c22525ad91604a00fad690d4e60004?_c=feed-rss-full&quot;&gt;Send to a friend&lt;/a&gt; 
&lt;/p&gt;
 
            </description>   
        </item> 
 
        <item>
            <title>Oops</title>
            <link>http://jcoehoorn.vox.com/library/post/oops.html?_c=feed-rss-full</link>   
            <author>nobody@vox.com(jcoehoorn)</author>
            <comments>http://jcoehoorn.vox.com/library/post/oops.html?_c=feed-rss-full</comments>
            <guid isPermaLink="true">http://jcoehoorn.vox.com/library/post/oops.html?_c=feed-rss-full</guid> 
            <pubDate>Thu, 12 Jun 2008 13:12:33 -0700</pubDate>         
            
            <description>    &lt;p&gt;So it&amp;#39;s been a while since my last update.&amp;#160; In truth, I just haven&amp;#39;t felt like writing.&amp;#160; It never fails that the same time I put the update schedule in the title is when I finally cave- though I did make it for several months.&amp;#160; Anyway, I do have a few topics coming, but I don&amp;#39;t know how often I&amp;#39;ll be updating so I took the schedule down. &lt;/p&gt;    &lt;p style=&quot;clear:both;&quot;&gt; 
    &lt;a href=&quot;http://jcoehoorn.vox.com/library/post/oops.html?_c=feed-rss-full#comments&quot;&gt;Read and post comments&lt;/a&gt;   |   
    &lt;a href=&quot;http://www.vox.com/share/6a00c22525ad91604a00fad68ff2900005?_c=feed-rss-full&quot;&gt;Send to a friend&lt;/a&gt; 
&lt;/p&gt;
 
            </description>   
        </item> 
 
        <item>
            <title>Screen Scraping ASP.Net</title>
            <link>http://jcoehoorn.vox.com/library/post/screen-scraping-aspnet.html?_c=feed-rss-full</link>   
            <author>nobody@vox.com(jcoehoorn)</author>
            <comments>http://jcoehoorn.vox.com/library/post/screen-scraping-aspnet.html?_c=feed-rss-full</comments>
            <guid isPermaLink="true">http://jcoehoorn.vox.com/library/post/screen-scraping-aspnet.html?_c=feed-rss-full</guid> 
            <pubDate>Wed, 14 May 2008 07:47:00 -0700</pubDate>         
            
            <description>    &lt;p&gt;I consider myself to be pretty good at scraping web sites.&amp;#160; I&amp;#39;ve been able to get into sites others thought where impossible.&amp;#160; I&amp;#39;ve even made it through some pretty tricky login verification.&amp;#160; My tool of choice to accomplish this is VB.Net and a simple class I&amp;#39;ve written that re-implements much of System.Net.Webclient, and extends it to support a few additional functions.&amp;#160; Unfortunately, I&amp;#39;m not ready to release that class here yet- there are still some issues with it I want to work out first.&lt;/p&gt;&lt;p&gt;The real key to scraping a web site isn&amp;#39;t the technology, anyway.&amp;#160; Scraping a given page, once you have it,
is and always will be rather trivial.&amp;#160; It&amp;#39;s when you&amp;#39;re scraping a site where you
may have to make several requests in sequence to get the server to create the page
you want that things can get tricky.&amp;#160; With that in mind, the key to successfully scraping a web site is simply to study client source for the site until you can accurately reproduce http requests that are the same or sufficiently similar to those issued by a web browser under the command of a normal user.&amp;#160; This may mean parsing some very nasty javascript now and then, but that&amp;#39;s they way it works.&amp;#160; Of course, there are tools that can help with this, but when it comes down to it you usually just need to be able to read the code.&lt;/p&gt;&lt;p&gt;Today I was helping someone scrape an ASP.Net site.&amp;#160; This was my first time scraping ASP.Net, which surprised me considering it&amp;#39;s my web platform of choice.&amp;#160; I was also shocked to discover that ASP.Net can be unusually difficult to scrape.&amp;#160; Perhaps in hindsight I should have known this, but it caught me unaware this morning.&amp;#160; &lt;/p&gt;&lt;p&gt;You see, ASP.Net pages include a few extra things by default that must go with every request.&amp;#160; The hidden __ViewState field, for example.&amp;#160; The server normally does some basic validation on the application state, so just sending an empty view state may not cut it.&amp;#160; Also, most server controls send requests using very cryptic IDs via an __doPostBack() javascript function.&amp;#160; It&amp;#39;s actually quite difficult to follow.&amp;#160; More than that, since it&amp;#39;s so easy to push the work for simple controls to the server, it&amp;#39;s very easy to obfuscate what a particular link is really doing.&amp;#160; So easy that you may even end up hiding things&amp;#160;by accident.&lt;/p&gt;&lt;p&gt;I figure after I get a little more experience scraping these pages I&amp;#39;ll discover there&amp;#39;s a trick to it, and once you know the trick they may even turn out to be easier.&amp;#160; In fact, I would expect that knowing a site uses ASP.Net would allow you to make certain assumptions about what fields you need to submit and how to submit them. &lt;/p&gt;&lt;p&gt;So if you have a web site and you want to protect it from scrapers, well... there&amp;#39;s really not much you can do.&amp;#160; Once a page is sent to a web browser a smart programmer will always be able to decipher it.&amp;#160; But you could do worse than to choose ASP.Net.&lt;br /&gt;&lt;/p&gt;    &lt;p style=&quot;clear:both;&quot;&gt; 
    &lt;a href=&quot;http://jcoehoorn.vox.com/library/post/screen-scraping-aspnet.html?_c=feed-rss-full#comments&quot;&gt;Read and post comments&lt;/a&gt;   |   
    &lt;a href=&quot;http://www.vox.com/share/6a00c22525ad91604a00fa967556ea0003?_c=feed-rss-full&quot;&gt;Send to a friend&lt;/a&gt; 
&lt;/p&gt;
 
            </description>   
        </item> 
 
        <item>
            <title>The End is Near</title>
            <link>http://jcoehoorn.vox.com/library/post/the-end-is-near.html?_c=feed-rss-full</link>   
            <author>nobody@vox.com(jcoehoorn)</author>
            <comments>http://jcoehoorn.vox.com/library/post/the-end-is-near.html?_c=feed-rss-full</comments>
            <guid isPermaLink="true">http://jcoehoorn.vox.com/library/post/the-end-is-near.html?_c=feed-rss-full</guid> 
            <pubDate>Mon, 05 May 2008 12:28:11 -0700</pubDate>         
            
            <description>    &lt;p&gt;Get out your tinfoil hats.&amp;#160; It turns out that a small part of Windows was &lt;a href=&quot;http://blogs.msdn.com/oldnewthing/archive/2008/05/05/8459022.aspx&quot;&gt;written by a machine&lt;/a&gt;.&amp;#160; You have to read through&amp;#160;most of a rather boring post to see what I&amp;#39;m talking about, and if you blink you might even miss it, but it&amp;#39;s there.&amp;#160; This isn&amp;#39;t an official Microsoft&amp;#160;statement, but it&amp;#160;is an officially sanctioned blog of a senior Microsoft engineer.&amp;#160; I&amp;#39;m sensationalizing this more than a little, but I&amp;#39;m sure there are those who will see this as a sort of slippery slope and wonder where it ends.&lt;/p&gt;    &lt;p style=&quot;clear:both;&quot;&gt; 
    &lt;a href=&quot;http://jcoehoorn.vox.com/library/post/the-end-is-near.html?_c=feed-rss-full#comments&quot;&gt;Read and post comments&lt;/a&gt;   |   
    &lt;a href=&quot;http://www.vox.com/share/6a00c22525ad91604a00f48d13e0d80001?_c=feed-rss-full&quot;&gt;Send to a friend&lt;/a&gt; 
&lt;/p&gt;
 
            </description>   
        </item> 
    </channel>
</rss>

