{"id":652,"date":"2005-07-20T08:48:58","date_gmt":"2005-07-20T13:48:58","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=652"},"modified":"2016-10-14T10:39:10","modified_gmt":"2016-10-14T14:39:10","slug":"code-wash","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2005\/07\/20\/code-wash\/","title":{"rendered":"Code wash"},"content":{"rendered":"<p><div class=\"alert alert-info\"> <span class=\"alert_icon icon-alert-info-reverse\"><\/span><p class=\"alert_heading\"><strong>Note<\/strong><\/p><p>The file submission referenced in this post is no longer available on File Exchange.<\/p><\/div><\/p>\n<p>Computers do not care about beautiful code.  Anyone can write code that a computer will like.  However, the challenge is to write code that both the computer and a computer programmer will like.  Much of that comes from good formating. This tool is good for helping with that.<\/p>\n<p>Compare the following:<\/p>\n<pre class=\"code\">a = [72 69 76 76 79 12 0 87 79 82 76 68 1]; b=32;\r\nobsficate=1;\r\nfor i=numel(a):-1:1; a(i)=a(i)+b+floor(.5); end\r\nif (nnz(obsficate)==2)|(obsficate==1)\r\nchar(a)\r\nend<\/pre>\n<p>Then put it through codeWash to get this:<\/p>\n<pre class=\"code\">a = [72 69 76 76 79 12 0 87 79 82 76 68 1];\r\nb = 32;\r\nobsficate = 1;\r\nfor i=numel(a):-1:1;\r\n   a(i)=a(i)+b+floor(0.5);\r\nend\r\nif (nnz(obsficate) == 2)|(obsficate == 1)\r\n   char(a)\r\nend<\/pre>\n<p>It is still horrible code, but at least it is now well formatted.  I have been wanting a &#8216;beautify&#8217; function added to the editor for a while now.  The next time someone hands me some ugly code I will run this so that I can have a fighting chance at understanding it.<\/p>\n<p>Also, as you may have noticed, I have not been selecting picks for a while.  Scott has been good about doing it while I have been extra busy.  I will be making a follow up video when things slow down a little around the office.  Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":"<p> NoteThe file submission referenced in this post is no longer available on File Exchange.<br \/>\nComputers do not care about beautiful code.  Anyone can write code that a computer will like.  However, the&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2005\/07\/20\/code-wash\/\">read more >><\/a><\/p>\n","protected":false},"author":68,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/652"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/68"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=652"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/652\/revisions"}],"predecessor-version":[{"id":7942,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/652\/revisions\/7942"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}