{"id":19196,"date":"2017-09-20T22:54:12","date_gmt":"2017-09-21T03:54:12","guid":{"rendered":"http:\/\/blog.kenperlin.com\/?p=19196"},"modified":"2017-09-20T22:54:12","modified_gmt":"2017-09-21T03:54:12","slug":"messcleanup-algorithms","status":"publish","type":"post","link":"https:\/\/blog.kenperlin.com\/?p=19196","title":{"rendered":"Mess\/cleanup algorithms"},"content":{"rendered":"<p>I used to use a very ambitious approach to computer algorithms that create structure.  If I wanted to, for example, construct a level surface from volumetric data, I would carefully build a coherent structure as the algorithm ran, maintaining order at every step.<\/p>\n<p>This would generally require some pretty gnarly code, with lots of dynamic data pointers and intricate logic in the inner loop.  In a way it was all quite beautiful, but also fragile and difficult to maintain.  A single ill considered change to the code could bring the whole delicate structure crashing down.<\/p>\n<p>I notice that these days I take a different approach, which might be called mess\/cleanup.  I run a first pass without worrying too much about structure.  In that pass I record just enough info along the way so that I can do the rest in a second pass.<\/p>\n<p>That second pass is where I build all the actual structure, using the info I&#8217;d recorded earlier.  The result ends up being the same, but the process is very different.<\/p>\n<p>Doing it this way, I find that my code is much smaller and more compact, and a lot easier to read.  There are fewer errors, and debugging is a piece of cake.<\/p>\n<p>So it seems that a little messiness is a useful thing when you&#8217;re writing tricky algorithms.  Not too much of a mess, but just enough.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I used to use a very ambitious approach to computer algorithms that create structure. If I wanted to, for example, construct a level surface from volumetric data, I would carefully build a coherent structure as the algorithm ran, maintaining order at every step. This would generally require some pretty gnarly code, with lots of dynamic &hellip; <a href=\"https:\/\/blog.kenperlin.com\/?p=19196\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Mess\/cleanup algorithms&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.kenperlin.com\/index.php?rest_route=\/wp\/v2\/posts\/19196"}],"collection":[{"href":"https:\/\/blog.kenperlin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kenperlin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kenperlin.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kenperlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=19196"}],"version-history":[{"count":1,"href":"https:\/\/blog.kenperlin.com\/index.php?rest_route=\/wp\/v2\/posts\/19196\/revisions"}],"predecessor-version":[{"id":19197,"href":"https:\/\/blog.kenperlin.com\/index.php?rest_route=\/wp\/v2\/posts\/19196\/revisions\/19197"}],"wp:attachment":[{"href":"https:\/\/blog.kenperlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=19196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kenperlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=19196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kenperlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=19196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}