<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Object Mentor Blog: Clues For Reading New Code</title>
    <link>http://blog.objectmentor.com/articles/2008/03/05/clues-for-reading-new-code</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Clues For Reading New Code</title>
      <description>&lt;p&gt;Okay, somebody just handed you a new chunk of code to work on.  Your first though on opening the file is &amp;#8220;Why, dear God, why?&amp;#8221;.  How do you get a handle on this masterpiece of clever programming?  Let&amp;#8217;s look for a few clues.&lt;/p&gt;


	&lt;p&gt;Where to start?&lt;/p&gt;


&lt;h2&gt;Documents&lt;/h2&gt;

	&lt;p&gt;Why not look at the documentation? &amp;lt;&lt;strong&gt;laughs&lt;/strong&gt;&amp;gt; Just kidding.  You know there&amp;#8217;s no documentation, and it&amp;#8217;s probably not useful.&lt;/p&gt;


&lt;h2&gt;People and Interactions&lt;/h2&gt;

	&lt;p&gt;You need a partner who is familiar with the code. Having a guide is better than having a map. Not only will you know where to go, but you&amp;#8217;ll know &amp;#8217;&amp;#8217;how&amp;#8217;&amp;#8217; to go and where not to step. Other people are a wonderful resource. Just don&amp;#8217;t settle for someone doing the work in front of you&amp;#8230; the goal is to learn as much as to do.&lt;/p&gt;


&lt;h2&gt;No, really, documents!&lt;/h2&gt;

	&lt;p&gt;&lt;span class="caps"&gt;OTOH&lt;/span&gt;, if you have somethng in the way of a summary or architectural overview, that might help. I&amp;#8217;d read the abstract and look at the pictures.  We&amp;#8217;re after big-picture, so &lt;strong&gt;read&lt;/strong&gt; it only, don&amp;#8217;t &lt;strong&gt;trust&lt;/strong&gt; it. Documents are seldom accurate, and seldom for long.  It might be good preparation for your partner&amp;#8217;s visit.&lt;/p&gt;


&lt;h2&gt;Use The Tests, Luke&lt;/h2&gt;

	&lt;p&gt;Do you have tests?  If you are in a test-driven shop, looking at unit tests is a good idea. If they&amp;#8217;re written well, they are specifications (by example) of the system.  If they&amp;#8217;re written poorly, you know where to start your work at least. Your partner could do a great service by helping clean up the code instead of explaining it.&lt;/p&gt;


	&lt;p&gt;No tests? Uh, oh.  No tests &lt;strong&gt;and&lt;/strong&gt; no doc?  Now you&amp;#8217;re in trouble.&lt;/p&gt;


&lt;h2&gt;Scan the File Space&lt;/h2&gt;

	&lt;p&gt;Are the classes well-named? Do you know where to begin working? If you can find code by looking at file names then you&amp;#8217;ve got the handle you need.  Your partner can help improve file naming if you find the code you&amp;#8217;ve been handed is in ill-named files.&lt;/p&gt;


	&lt;p&gt;So you&amp;#8217;re in a file, you have a mission.  Either you have tests, or you&amp;#8217;re ready to write some.&lt;/p&gt;


&lt;h2&gt;Sense Of Smell&lt;/h2&gt;

	&lt;p&gt;What if the code is still not obvious?  You have one more resource before you have to print out the listing and break out the markers to reverse-engineer your way out of code hell.  You have your nose and your refactoring editor.  You can use refactorings such as &amp;#8216;rename&amp;#8217;, &amp;#8216;extract method&amp;#8217;, and &amp;#8216;introduce variable&amp;#8217; to clarify an existing method. You can spot duplication and eliminate it.  Maybe you can bring it to a point of clarity, and then you will know&lt;/p&gt;


&lt;h2&gt;Deep Code Spelunking&lt;/h2&gt;

	&lt;p&gt;It&amp;#8217;s time to pour a really big cup of tea, get some food, take a couple of preemptive aspirin, and make sure your printer has paper.&lt;/p&gt;


	&lt;p&gt;Sometimes, you will have to reverse-engineer some of the code you were handed. Your only hope may be to rebuild it from the inside-out.&lt;/p&gt;


	&lt;p&gt;You might want to either copy the code to a scratch space to do this.  Maybe you want to branch the project in version control.  You want to be free to dig in an learn this the hard way, and make it better as you emerge from the depths.&lt;/p&gt;


	&lt;p&gt;You still can/must use refactoring tricks to capture the knowledge you gain, but you may need to take the code off line. And look for new partners.&lt;/p&gt;</description>
      <pubDate>Wed, 05 Mar 2008 19:27:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:5a6bcbe7-686d-4cf3-8b45-6eb95e45c65e</guid>
      <author>Tim Ottinger</author>
      <link>http://blog.objectmentor.com/articles/2008/03/05/clues-for-reading-new-code</link>
      <category>Tim's Tepid Torrent</category>
    </item>
    <item>
      <title>"Clues For Reading New Code" by Patrick Smacchia</title>
      <description>&lt;p&gt;There are now some tools that can help a lot understanding a code base. Have a look at this features of the tool NDepend for example:
&lt;a href="http://www.ndepend.com/Features.aspx" rel="nofollow"&gt;http://www.ndepend.com/Features.aspx&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Sun, 30 Mar 2008 10:45:55 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:adc7cd4d-8033-476d-a561-2a5f3c5a9c12</guid>
      <link>http://blog.objectmentor.com/articles/2008/03/05/clues-for-reading-new-code#comment-1675</link>
    </item>
    <item>
      <title>"Clues For Reading New Code" by Rob Wehrli</title>
      <description>&lt;p&gt;I think that one of the most practical and immediately beneficial methods of &amp;#8220;interfacing&amp;#8221; with new code begins with doxygen -g and editing the Doxyfile.  Granted, it doesn&amp;#8217;t support every programming language ever invented, but it definitely covers the 80/20 rule.&lt;/p&gt;


	&lt;p&gt;Even uncommented code is traversable using Doxygen output.&lt;/p&gt;


	&lt;p&gt;Perhaps this is a hyper-extension to &amp;#8220;Scan the File Space,&amp;#8221; but it works well and the cash outlay is FREE + TIME.&lt;/p&gt;


	&lt;p&gt;Take Care.&lt;/p&gt;


	&lt;p&gt;Rob!&lt;/p&gt;</description>
      <pubDate>Thu, 13 Mar 2008 16:42:47 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:22a46e7f-2d4a-4058-83a8-76b9b1a4d76f</guid>
      <link>http://blog.objectmentor.com/articles/2008/03/05/clues-for-reading-new-code#comment-1660</link>
    </item>
    <item>
      <title>"Clues For Reading New Code" by Brian</title>
      <description>&lt;p&gt;&amp;#8220;Why not look at the documentation?  Just kidding. You know there&#226;&#8364;&#8482;s no documentation, and it&#226;&#8364;&#8482;s probably not useful.&amp;#8221;&lt;/p&gt;


	&lt;p&gt;LOL so true!!! :)&lt;/p&gt;


	&lt;p&gt;&amp;#8212;Brian
&lt;a href="http://www.BrianDiCroce.com" rel="nofollow"&gt;www.BrianDiCroce.com&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 13 Mar 2008 15:37:22 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:39305474-9ee0-436b-be18-d143ddec2fc3</guid>
      <link>http://blog.objectmentor.com/articles/2008/03/05/clues-for-reading-new-code#comment-1659</link>
    </item>
    <item>
      <title>"Clues For Reading New Code" by Prashant Rane</title>
      <description>&lt;p&gt;Code Analysis tools could help you here. Structure 101, Eclipse XRay plugin, Eclipse CAP plugin, MaintainJ, NetBeans UML support etc. can help you get the handle on the codebase.&lt;/p&gt;</description>
      <pubDate>Wed, 12 Mar 2008 16:13:04 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:bd4bfe19-705a-4e70-ac40-ec2bf36763e3</guid>
      <link>http://blog.objectmentor.com/articles/2008/03/05/clues-for-reading-new-code#comment-1656</link>
    </item>
    <item>
      <title>"Clues For Reading New Code" by Alex Miller</title>
      <description>&lt;p&gt;Nice ideas.  You might find my blog on &lt;a href="http://tech.puredanger.com/2007/09/18/spelunking/" rel="nofollow"&gt;code spelunking&lt;/a&gt;  to be a natural companion.&lt;/p&gt;</description>
      <pubDate>Wed, 12 Mar 2008 14:57:27 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:926f83cf-67f2-4c5b-a036-44055b0d2bb0</guid>
      <link>http://blog.objectmentor.com/articles/2008/03/05/clues-for-reading-new-code#comment-1655</link>
    </item>
    <item>
      <title>"Clues For Reading New Code" by ik_5</title>
      <description>&lt;p&gt;On open source projects, I usually do grep to look for something I do know, and try to go from there&amp;#8230; sometimes traveling with the code can gives you a lot of answers on the person who wrote it and how they think, and then it&amp;#8217;s easier.&lt;/p&gt;


	&lt;p&gt;I have learned not to use graphics tools because they usually omit few things, so the more basic your tools  are, the easier it is for you to find your hands and feet.&lt;/p&gt;


	&lt;p&gt;Having said that, it&amp;#8217;s always good to find someone that already know whats going on, that can direct you (like the author here wrote) ;)&lt;/p&gt;</description>
      <pubDate>Mon, 10 Mar 2008 06:24:01 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:3a1d9f41-6bfb-461c-ab0c-69ac695e11cf</guid>
      <link>http://blog.objectmentor.com/articles/2008/03/05/clues-for-reading-new-code#comment-1649</link>
    </item>
    <item>
      <title>"Clues For Reading New Code" by dmitry</title>
      <description>&lt;p&gt;At the last SoCal CodeCamp Woody Zuill gave an excellent talk on how to use mocks for exploratory programming of legacy code: &lt;a href="http://zuill.us/WoodyZuill/2008/01/14/nmock2-as-a-code-exploration-tool/" rel="nofollow"&gt;http://zuill.us/WoodyZuill/2008/01/14/nmock2-as-a-code-exploration-tool/&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 06 Mar 2008 12:15:59 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:f4bfc8c4-ee42-45d3-b7f1-0e98c5fc6207</guid>
      <link>http://blog.objectmentor.com/articles/2008/03/05/clues-for-reading-new-code#comment-1637</link>
    </item>
    <item>
      <title>"Clues For Reading New Code" by JJ</title>
      <description>&lt;p&gt;Haha very good introduction. This should teach all the newbies to know what they&amp;#8217;re getting into.&lt;/p&gt;</description>
      <pubDate>Thu, 06 Mar 2008 08:14:39 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:755e58e6-f4b1-4897-9e10-e0eb71f7a4b3</guid>
      <link>http://blog.objectmentor.com/articles/2008/03/05/clues-for-reading-new-code#comment-1635</link>
    </item>
  </channel>
</rss>
