{
  "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/03/17/cleaner-cdk-code-2-stringcontains-and.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/kf1jt-xmf65",
      "url": "https://chem-bla-ics.linkedchemistry.info/2010/03/17/cleaner-cdk-code-2-stringcontains-and.html",
      "title": "Cleaner CDK Code #2: String.contains() and logger messages",
      "content_html": "<p>Second in the series (see <a href=\"https://chem-bla-ics.linkedchemistry.info/2010/03/07/cleaner-cdk-code-1-list-and-for-each.html\">#1 <i class=\"fa-solid fa-recycle fa-xs\"></i></a>),\nwith two rather small tips.</p>\n\n<h2 id=\"use-stringcontains-instead-of-stringindexoffoo---1\">Use String.contains() instead of String.indexOf(“foo”) != -1</h2>\n\n<p>Java 5 introduced the method <a href=\"http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#contains(java.lang.CharSequence)\">public boolean contains(CharSequence s)</a>,\nwhich can replace the more cryptic use of <em>indexOf() != -1</em>.</p>\n\n<p>Instead of:</p>\n\n<div class=\"language-java highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nc\">System</span><span class=\"o\">.</span><span class=\"na\">getProperty</span><span class=\"o\">(</span><span class=\"s\">\"java.version\"</span><span class=\"o\">).</span><span class=\"na\">indexOf</span><span class=\"o\">(</span><span class=\"s\">\"1.6\"</span><span class=\"o\">)</span> <span class=\"o\">!=</span> <span class=\"o\">-</span><span class=\"mi\">1</span>\n</code></pre></div></div>\n\n<p>you can write:</p>\n\n<div class=\"language-java highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nc\">System</span><span class=\"o\">.</span><span class=\"na\">getProperty</span><span class=\"o\">(</span><span class=\"s\">\"java.version\"</span><span class=\"o\">).</span><span class=\"na\">contains</span><span class=\"o\">(</span><span class=\"s\">\"1.6\"</span><span class=\"o\">)</span>\n</code></pre></div></div>\n\n<h2 id=\"more-efficient-use-of-the-loggingtool\">More efficient use of the LoggingTool</h2>\n\n<p>Quite a long time ago, <a href=\"http://www.jmol.org/\">Jmol</a> developer Miguel introduced me to a nice performance hint with respect to using\nlogging tools. Each debug(), info(), warn(), etc method should take more than one parameter, so that only when debugging (or the debug\nlevel) is turned on, the objects are concatenated. It indeed gave a considerable performance boost to things. The CDK supports this\ntoo, and you should not concatenate Strings and other objects, but let the LoggingTool do that.</p>\n\n<p>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>\n  <span class=\"s\">\"\\n\"</span> <span class=\"o\">+</span> <span class=\"n\">paths</span><span class=\"o\">.</span><span class=\"na\">size</span><span class=\"o\">()</span> <span class=\"o\">+</span> <span class=\"s\">\" paths and \"</span> <span class=\"o\">+</span>\n  <span class=\"n\">ac</span><span class=\"o\">.</span><span class=\"na\">getAtomCount</span><span class=\"o\">()</span> <span class=\"o\">+</span> <span class=\"s\">\" atoms left.\"</span>\n<span class=\"o\">);</span>\n</code></pre></div></div>\n\n<p>you can 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>\n  <span class=\"s\">\"\\n\"</span><span class=\"o\">,</span> <span class=\"n\">paths</span><span class=\"o\">.</span><span class=\"na\">size</span><span class=\"o\">(),</span> <span class=\"s\">\" paths and \"</span><span class=\"o\">,</span>\n  <span class=\"n\">ac</span><span class=\"o\">.</span><span class=\"na\">getAtomCount</span><span class=\"o\">(),</span> <span class=\"s\">\" atoms left.\"</span>\n<span class=\"o\">);</span>\n</code></pre></div></div>",
      "summary": "Second in the series (see #1 ), with two rather small tips.",
      
      "date_published": "2010-03-17T00:00:00+00:00",
      "date_modified": "2026-09-27T00:00:00+00:00",
      "tags": ["cdk","java"],
      
      
      
      
      
      
        "authors": [ { "name": "Egon Willighagen", "url": "https://orcid.org/0000-0001-7542-0286" } ]
      
    }

  ]
}
