{"id":3953,"date":"2014-03-16T02:44:15","date_gmt":"2014-03-16T07:44:15","guid":{"rendered":"http:\/\/www.thejuliagroup.com\/blog\/?p=3953"},"modified":"2014-03-18T04:37:44","modified_gmt":"2014-03-18T09:37:44","slug":"how-many-lines-of-code-have-you-deleted","status":"publish","type":"post","link":"https:\/\/www.thejuliagroup.com\/blog\/how-many-lines-of-code-have-you-deleted\/","title":{"rendered":"How many lines of code have you deleted?"},"content":{"rendered":"<p>One of the many questions on start-up accelerator applications that make me go &#8220;Hmm&#8221;, is this question :<\/p>\n<p>How many lines of code have you written?<\/p>\n<p>I have heard of, but thankfully never worked at, organizations that evaluated their technical staff by the lines of code written.<\/p>\n<p>Let me give you two stories that illustrate why this is a bad example.<\/p>\n<p><a href=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/07\/fairy.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2537\" alt=\"fairy\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/07\/fairy-196x300.jpg\" width=\"196\" height=\"300\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/07\/fairy-196x300.jpg 196w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/07\/fairy.jpg 323w\" sizes=\"auto, (max-width: 196px) 100vw, 196px\" \/><\/a><\/p>\n<p>Once upon a time &#8230;.<\/p>\n<p>Many years ago, I worked at an organization that decided the programming staff was overpaid and generally had a bad attitude. (No, this wasn&#8217;t due solely to me. In fact, unbelievably, I was one of the easier to get along with people on the technical staff). \u00a0So &#8230; they hired some people at low salaries who had, I believe, a three-month training course in SAS. Most of the senior people avoided the cube farm where these new hires were housed, believing that it would be apparent soon enough that you get what you pay for.<\/p>\n<p>I would generally come in around 10:30 or 11 and leave the office around 8 pm. I couldn&#8217;t help but notice several times that some of these new programmers were still there when I left. Leaving one evening, I saw one woman in tears in her cubicle, so I stopped and asked what was the matter. She said she had come into the office at 6 a.m. and was still waiting for her program to run. I sat down with her and looked at her program, which was a simple thing to create a few total and subtotal scores and get statistics on these by state. Her program looked like this:<\/p>\n<p>&nbsp;<\/p>\n<p>LIBNAME \u00a0in &#8220;directory&#8221;;<\/p>\n<p>Data Alabama ;<br \/>\nset in.us ;<br \/>\nIf var1 = . \u00a0then var1 = 0 ;<br \/>\nIf var2 = . \u00a0then var2 = 0 ;<br \/>\nIf var3 = . \u00a0then var3 = 0 ;<br \/>\nTotal = var1 + var 2 + var 3;<br \/>\nIf state= &#8220;Alabama&#8221; ;<\/p>\n<p>run;<br \/>\nProc means data = alabama ;<br \/>\nvar total ;<br \/>\nrun;<\/p>\n<p>REPEATED 50 TIMES (50 states + Washington, DC) for a total of 562 lines of code (there is only one Libname statement).<\/p>\n<p>The reason it was taking so long is that she was reading in this dataset with millions of records 51 times. There are many ways this could be fixed. Since I was on my way home, I sat down and did this.<\/p>\n<p>libname mydata &#8220;directory&#8221; \u00a0;<br \/>\ndata test ;<br \/>\nset mydata.us ;<br \/>\ntotal = sum(var1,var2,var3) ;<br \/>\nkeep total state ;<\/p>\n<p>Proc tabulate data= test ;<br \/>\nclass state ;<br \/>\nvar total ;<br \/>\nTable state ,(total*(n*f=comma12.0(mean std)*f=comma8.2) );<br \/>\nrun ;<\/p>\n<p>My program was 10 lines, read the dataset in once and produced a nicely formatted table.<\/p>\n<p>So, was she 60 times more productive? I don&#8217;t think so.<\/p>\n<p><strong>Story number two happened in the last week.<\/strong> I have been working on improving our two games, Spirt Lake, and particularly Fish Lake. A major improvement has been merging multiple scripts into one.<\/p>\n<p>Here is what we did with our prototype, since we had to meet a deadline:<\/p>\n<ul>\n<li>Wrote a script to handle multiple choice tests.<\/li>\n<li>Wrote another script to handle tests that had an integer or decimal answer.<\/li>\n<li>Wrote a third script to handle tests that had a fraction as an answer, like 4\/5 , to be sure it also accepted 8\/10, etc.<\/li>\n<li>Wrote a fourth script to handle tests where the answer was dragged and dropped.<\/li>\n<\/ul>\n<p>etc.<\/p>\n<p>Now obviously, de-bugging would be simpler if we have only one or two scripts. So, this week, I have been taking a couple of scripts and making them more generalizable and deleting many others.<\/p>\n<p>Another thing I&#8217;ve done is create a CSS style sheet for each game and included that link in files instead of having the common classes defined in each page.<\/p>\n<p>&nbsp;<\/p>\n<p>The number of code in the project has gone DOWN by hundreds of lines, but I think the ease of maintenance and documentation has gone UP.<\/p>\n<p>Now, if you asked me how many lines of code I have written in my life, that might be a relevant question. (True story, I once worked on a job where I did repeated measures ANOVA so many times for so many projects, I got so bored, I started writing statements backward beginning with the semi-colon.)<\/p>\n<p>Well, I better get to bed since it is well past midnight, I have seven teenagers sleeping over at my house and I have to get up in the morning and take them all to Disneyland for The Spoiled One&#8217;s birthday.<\/p>\n<p><a href=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2013\/08\/7-Generation-Games-LogoMed.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-3517\" alt=\"7 Generation Games Logo\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2013\/08\/7-Generation-Games-LogoMed-300x112.jpg\" width=\"300\" height=\"112\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2013\/08\/7-Generation-Games-LogoMed-300x112.jpg 300w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2013\/08\/7-Generation-Games-LogoMed.jpg 507w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.7generationgames.com\/purchase\/\">BTW &#8211; You can buy Spirit Lake: The Game here\u00a0<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the many questions on start-up accelerator applications that make me go &#8220;Hmm&#8221;, is this question : How many lines of code have you written? I have heard of, but thankfully never worked at, organizations that evaluated their technical staff by the lines of code written. Let me give you two stories that illustrate&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1,9],"tags":[],"class_list":["post-3953","post","type-post","status-publish","format-standard","hentry","category-dr-de-mars-general-life-ramblings","category-software"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/posts\/3953","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/comments?post=3953"}],"version-history":[{"count":5,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/posts\/3953\/revisions"}],"predecessor-version":[{"id":3967,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/posts\/3953\/revisions\/3967"}],"wp:attachment":[{"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/media?parent=3953"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/categories?post=3953"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/tags?post=3953"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}