{
  "version": "https://jsonfeed.org/version/1.1",
  "title": "chem-bla-ics",
  "description": "Chemblaics (pronounced chem-bla-ics) is the science that uses open science and computers to solve problems in chemistry, biochemistry and related fields.",
  "home_page_url": "https://chem-bla-ics.linkedchemistry.info/",
  "feed_url": "https://chem-bla-ics.linkedchemistry.info/2010/08/05/cleaner-cdk-code-7-understand-what-code.json",
  "icon": "https://chem-bla-ics.linkedchemistry.info/assets/images/chem-bla-ics_logo.png",
  "language": "en",
  "authors": [
    {
      "name": "Egon Willighagen",
      "url": "https://orcid.org/0000-0001-7542-0286",
      "_orcid": "0000-0001-7542-0286"
    }
  ],
  "items": [

    {
      "id": "https://doi.org/10.59350/0a1n4-5q396",
      "url": "https://chem-bla-ics.linkedchemistry.info/2010/08/05/cleaner-cdk-code-7-understand-what-code.html",
      "title": "Cleaner CDK Code #7: understand what the code is supposed to do",
      "content_html": "<p>It has been a while since I posted a blog post in this series (see below for a full list so far), but was fixing a problem for Nina\n(<a href=\"http://www.opentox.org/\">OpenTox</a>), and found some code I did not understand. So, here’s another useful tip (IMHO) for writing\nCDK code. Well, in particular, patching CDK code in this case.</p>\n\n<h3 id=\"understand-what-the-code-is-doing\">Understand what the code is doing</h3>\n\n<p>Understanding what <a href=\"http://cdk.sf.net/\">CDK</a> code is doing is not always obvious. Theoretically, the mix of clean code, JavaDoc,\nand code comments explain enough, but sometimes it is not. Then, it is useful to see how code has evolved: who wrote the code;\nwhat was the commit message around that code (further documentation); what did the code look like before that change. This is\nwhere <em>git blame</em> comes in (see also how <a href=\"http://chem-bla-ics.blogspot.com/2010/05/how-to-use-github-for-cdkbioclipse-code.html\">GitHub used this</a>).</p>\n\n<p>Now, to see the history of a source file, we do, for example:</p>\n\n<div class=\"language-shell highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>git pickaxe <span class=\"nt\">-L</span> 840 <span class=\"nt\">--</span> src/main/org/openscience/cdk/smiles/DeduceBondSystemTool.java\n</code></pre></div></div>\n\n<p>Which will output something like:</p>\n\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>00000000 (Not Committed Yet 2010-08-05 16:35:29 +0100 840)      *\n00000000 (Not Committed Yet 2010-08-05 16:35:29 +0100 841)      * @param interrupted true, if the calculation should be canceled\n00000000 (Not Committed Yet 2010-08-05 16:35:29 +0100 842)      */\n00000000 (Not Committed Yet 2010-08-05 16:35:29 +0100 843)     @TestMethod(\"testInterruption\")\n7c5c872c (egonw             2008-02-22 19:13:45 +0000 844)      public void setInterrupted(boolean interrupted) {\n7c5c872c (egonw             2008-02-22 19:13:45 +0000 845)              this.interrupted = interrupted;\n7c5c872c (egonw             2008-02-22 19:13:45 +0000 846)      }\n7c5c872c (egonw             2008-02-22 19:13:45 +0000 847)\n00000000 (Not Committed Yet 2010-08-05 16:35:29 +0100 848)     @TestMethod(\"testInterruption\")\n7c5c872c (egonw             2008-02-22 19:13:45 +0000 849)      public boolean isInterrupted() {\n7c5c872c (egonw             2008-02-22 19:13:45 +0000 850)              return this.interrupted;\n7c5c872c (egonw             2008-02-22 19:13:45 +0000 851)      }\n7c5c872c (egonw             2008-02-22 19:13:45 +0000 852)\n7c5c872c (egonw             2008-02-22 19:13:45 +0000 853) }\n</code></pre></div></div>\n\n<p>The uncommited parts shows a patch I am working on. You see that these methods have last been touched by me. So, it is interesting\nto see why I added those, for which we look up the commit message (using he commit hash in the first column). We use\n<code class=\"language-plaintext highlighter-rouge\">git show --shortstat 7c5c872c</code>:</p>\n\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>commit 7c5c872c6be0e6a24a519eb227e7ed0b76ac37d6\nAuthor: egonw\nDate:   Fri Feb 22 19:13:45 2008 +0000\n\n    Merged the branch egonw/maintest: sets up src/main and src/test for splitting main library from unit tests\n\n    git-svn-id: https://cdk.svn.sourceforge.net/svnroot/cdk/trunk/cdk@10219 eb4e18e3-b210-0410-a6ab-dec725e4b171\n\n 2340 files changed, 398392 insertions(+), 92370 deletions(-)\n</code></pre></div></div>\n\n<p>We now actually see an important commit in history. This was the commit where the source code was split up into the two folders we have right now.</p>\n\n<h3 id=\"dealing-with-moved-files\">Dealing with moved files</h3>\n\n<p>Normally, we could do the following to see what the code was like before this commit, by adding the revision hash and a ^ to indicate the last commit before that hash, with:</p>\n\n<div class=\"language-shell highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>git pickaxe <span class=\"nt\">-L</span> 840 7c5c872c^ <span class=\"nt\">--</span> src/main/org/openscience/cdk/smiles/DeduceBondSystemTool.java\n</code></pre></div></div>\n\n<p>However, this will not work here, because the source code originally was elsewhere. In particular, the code used to be all in src/. So, the original location was src/main/org/openscience/cdk/smiles/DeduceBondSystemTool.java. Therefore, we must use instead:</p>\n\n<div class=\"language-shell highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>git pickaxe <span class=\"nt\">-L</span> 840 7c5c872c^ <span class=\"nt\">--</span> src/org/openscience/cdk/smiles/DeduceBondSystemTool.java\n</code></pre></div></div>\n\n<p>And then we can continue again.</p>\n\n<h3 id=\"previous-topics\">Previous topics</h3>\n\n<ul>\n  <li><a href=\"https://chem-bla-ics.linkedchemistry.info/2010/05/21/cleaner-cdk-code-6-set-cdkexceptions.html\">Cleaner CDK Code #6: set the CDKException’s cause Exception <i class=\"fa-solid fa-recycle fa-xs\"></i></a></li>\n  <li><a href=\"https://chem-bla-ics.linkedchemistry.info/2010/05/15/cleaner-cdk-code-5-developer-against.html\">Cleaner CDK Code #5: develop against interfaces <i class=\"fa-solid fa-recycle fa-xs\"></i></a></li>\n  <li><a href=\"https://chem-bla-ics.linkedchemistry.info/2010/03/30/cleaner-cdk-code-4-inheriting-javadoc.html\">Cleaner CDK Code #4: inheriting JavaDoc from super classes and interfaces <i class=\"fa-solid fa-recycle fa-xs\"></i></a></li>\n  <li><a href=\"https://chem-bla-ics.linkedchemistry.info/2010/03/26/cleaner-cdk-code-3-run-pmd-tests.html\">Cleaner CDK Code #3: run the PMD tests <i class=\"fa-solid fa-recycle fa-xs\"></i></a></li>\n  <li><a href=\"http://chem-bla-ics.blogspot.com/2010/03/cleaner-cdk-code-2-stringcontains-and.html\">Cleaner CDK Code #2: String.contains() and logger messages</a></li>\n  <li><a href=\"https://chem-bla-ics.linkedchemistry.info/2010/03/07/cleaner-cdk-code-1-list-and-for-each.html\">Cleaner CDK Code #1: List and the for-each loop <i class=\"fa-solid fa-recycle fa-xs\"></i></a></li>\n</ul>",
      "summary": "It has been a while since I posted a blog post in this series (see below for a full list so far), but was fixing a problem for Nina (OpenTox), and found some code I did not understand. So, here’s another useful tip (IMHO) for writing CDK code. Well, in particular, patching CDK code in this case.",
      
      "date_published": "2010-08-05T00:00:00+00:00",
      "date_modified": "2026-09-27T00:00:00+00:00",
      "tags": ["cdk"],
      
      
      
      
      
      
        "authors": [ { "name": "Egon Willighagen", "url": "https://orcid.org/0000-0001-7542-0286" } ]
      
    }

  ]
}
