{"id":1304,"date":"2011-12-12T12:54:15","date_gmt":"2011-12-12T17:54:15","guid":{"rendered":"http:\/\/cd34.com\/blog\/?p=1304"},"modified":"2011-12-13T00:40:24","modified_gmt":"2011-12-13T05:40:24","slug":"documenting-projects-as-you-write-them","status":"publish","type":"post","link":"https:\/\/cd34.com\/blog\/programming\/python\/documenting-projects-as-you-write-them\/","title":{"rendered":"Documenting projects as you write them"},"content":{"rendered":"<p>In Feb 2009 I started converting a PHP application over to Python and a framework. Today, I have finished all of the functional code and am at the point where I need to write a number of interfaces to the message daemon (currently a Perl script I wrote after ripping apart a C\/libace daemon we had written).<\/p>\n<p>The code did work in prior frameworks, I&#8217;ve moved to Pyramid, but, now I&#8217;m having to figure out why I ever used __init__ with 13 arguments. Of course everything is a wrapper around a wrapper around a single call and nothing is documented other than some sparse comments. Encrypted RPC payloads are sent to the daemon &#8211; oops, I also changed the host and key I&#8217;m testing from.<\/p>\n<p>Yes, I actually am using RPC, in production, the right way.<\/p>\n<p>Total Physical Source Lines of Code (SLOC)                = 5,154<\/p>\n<p>The penultimate 3% has added almost 200 lines of code. I suspect the last 2% adding the interfaces will add another 100 or so lines. Had I written better internal documentation, getting pulled away from the project for weeks or months at a time would have resulted in less ramp-up time when sitting back down to code. There were a few times where it would take me a few hours just to get up to speed with something I had written 18 months ago because I didn&#8217;t know what my original intentions were, or, what problem I was fixing.<\/p>\n<p>Original PHP\/Smarty project:<\/p>\n<p>Total Physical Source Lines of Code (SLOC)                = 45,040<\/p>\n<p>In 2009, when I started this project, test code written resulted in roughly a 10:1 reduction in the codebase. It isn&#8217;t a truly fair comparison &#8212; the new code does more, has much better validation checks, and adds a number of features.<\/p>\n<p>It&#8217;s been a long road and I&#8217;ve faced a number of challenges along the way. After <a href=\"\/blog\/programming\/global-day-of-coderetreat\/\">Coderetreat<\/a>, I&#8217;ve attempted to write testing as I&#8217;m writing code. That is a habit that I&#8217;ll have to reinforce. I don&#8217;t know that I&#8217;ll actually do Test Driven Development, but, I can see more test code being written during development, rather than sitting down with the project after it is done and writing test code. Additionally, I&#8217;m going to use <a href=\"http:\/\/sphinx.pocoo.org\/\">Sphinx<\/a> even for internal documentation.<\/p>\n<p>People might question why I went with Turbogears, Pylons, and ended up with <a href=\"http:\/\/www.pylonsproject.org\/\">Pyramid<\/a>, but, at the time I evaluated a number of frameworks, <a href=\"https:\/\/www.djangoproject.com\/\">Django<\/a>&#8216;s ORM wasn&#8217;t powerful enough for some of the things I needed to do and I knew I needed to use <a href=\"http:\/\/www.sqlalchemy.org\/\">SQLAlchemy<\/a>. While Django and SQLAlchemy could be used at the time, I felt TurboGears was a closer match. As it turns out, Pyramid is just about perfect for me. Light enough that it doesn&#8217;t get in the way, heavy enough that it contains the hooks that I need to get things done.<\/p>\n<p>If I wrote a framework, and I have considered it, Pyramid is fairly close to what I would end up with.<\/p>\n<p>Lesson learned&#8230; document.<\/p>\n<p>Today is going to be a very frustrating day wiring up stuff to classmethods that have very little documentation and buried __init__ blocks. Yes, I&#8217;ll be documenting things today.<\/p>\n<div style=\"float:left;\">\n<div id=\"fb-root\"><\/div>\n<fb:like href=\"https:\/\/cd34.com\/blog\/programming\/python\/documenting-projects-as-you-write-them\/\" width=\"250\" send=\"false\" show_faces=\"false\" layout=\"button_count\" action=\"recommend\"><\/fb:like>\n<\/div><div style=\"clear:both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>In Feb 2009 I started converting a PHP application over to Python and a framework. Today, I have finished all of the functional code and am at the point where I need to write a number of interfaces to the message daemon (currently a Perl script I wrote after ripping apart a C\/libace daemon we [&hellip;]<\/p>\n<div style=\"float:left;\">\n<div id=\"fb-root\"><\/div>\n<fb:like href=\"https:\/\/cd34.com\/blog\/programming\/python\/documenting-projects-as-you-write-them\/\" width=\"250\" send=\"false\" show_faces=\"false\" layout=\"button_count\" action=\"recommend\"><\/fb:like>\n<\/div><div style=\"clear:both;\"><\/div>","protected":false},"author":15,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[219,148,299,220,49],"class_list":["post-1304","post","type-post","status-publish","format-standard","hentry","category-python","tag-documentation","tag-pyramid","tag-python","tag-sphinx","tag-sqlalchemy"],"_links":{"self":[{"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/posts\/1304","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/comments?post=1304"}],"version-history":[{"count":2,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/posts\/1304\/revisions"}],"predecessor-version":[{"id":1306,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/posts\/1304\/revisions\/1306"}],"wp:attachment":[{"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/media?parent=1304"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/categories?post=1304"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/tags?post=1304"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}