{
  "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/2011/02/24/cleaner-cdk-code-9-using-loggingtool.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/vd2z8-prh71",
      "url": "https://chem-bla-ics.linkedchemistry.info/2011/02/24/cleaner-cdk-code-9-using-loggingtool.html",
      "title": "Cleaner CDK Code #9: using the LoggingTool",
      "content_html": "<p>A trick I used from Miguel Howard (of <a href=\"http://www.jmol.org/\">Jmol</a> fame) is\nto not concatenate String until really needed. String concatenation will allocate\nnew Strings, and thus burden the garbage collector (yeah, you lucky Fortran\nusers who think twice before allocating memory :). Some time ago, he suggested\nthis trick for the logger. I think in Jmol, but the <a href=\"http://cdk.sf.net/\">CDK</a>\ninherited that idea.</p>\n\n<h2 id=\"dont-concatenate-strings-when-calling-the-loggingtool\">Don’t concatenate Strings when calling the LoggingTool</h2>\n\n<p>Logging in the CDK can be turned off, and in production use, I often do. Therefore,\nwe can make it speed up by concatenating debug message String only when debugging\nis turned on. The CDK <a href=\"http://pele.farmbio.uu.se/nightly/api/org/openscience/cdk/tools/ILoggingTool.html\">LoggingTool</a>\ncan take care of this, so you should pass the Strings are individual parameters\nto the logger call. Instead of:</p>\n\n<div class=\"language-java highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"n\">logger</span><span class=\"o\">.</span><span class=\"na\">debug</span><span class=\"o\">(</span><span class=\"s\">\"the current atom is \"</span> <span class=\"o\">+</span> <span class=\"n\">atom</span><span class=\"o\">);</span>\n</code></pre></div></div>\n\n<p>you should write:</p>\n\n<div class=\"language-java highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"n\">logger</span><span class=\"o\">.</span><span class=\"na\">debug</span><span class=\"o\">(</span><span class=\"s\">\"the current atom is \"</span><span class=\"o\">,</span> <span class=\"n\">atom</span><span class=\"o\">);</span>\n</code></pre></div></div>\n\n<p>And this works for any arbitrary number of Strings and objects, because the\nlogging tool debug method has this signature: <code class=\"language-plaintext highlighter-rouge\">public void debug(Object object,\nObject... objects)</code>. So, you can also just do:</p>\n\n<div class=\"language-java highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"n\">logger</span><span class=\"o\">.</span><span class=\"na\">debug</span><span class=\"o\">(</span><span class=\"s\">\"The \"</span><span class=\"o\">,</span> <span class=\"n\">i</span><span class=\"o\">,</span> <span class=\"s\">\"th object is connected to the \"</span><span class=\"o\">,</span> <span class=\"n\">j</span><span class=\"o\">,</span> <span class=\"s\">\"th\"</span><span class=\"o\">);</span>\n</code></pre></div></div>\n\n<p>Actually, looking at the <code class=\"language-plaintext highlighter-rouge\">debug()</code> method’s signature, I am not sure why we still\nhave the first Object separately… mmm.</p>",
      "summary": "A trick I used from Miguel Howard (of Jmol fame) is to not concatenate String until really needed. String concatenation will allocate new Strings, and thus burden the garbage collector (yeah, you lucky Fortran users who think twice before allocating memory :). Some time ago, he suggested this trick for the logger. I think in Jmol, but the CDK inherited that idea.",
      
      "date_published": "2011-02-24T00:10:00+00:00",
      "date_modified": "2011-02-24T00:10:00+00:00",
      "tags": ["cdk","cheminf","java"],
      
      
      
      
      
      
        "authors": [ { "name": "Egon Willighagen", "url": "https://orcid.org/0000-0001-7542-0286" } ]
      
    }

  ]
}
