Linking explicit and implicit knowledge
More on the meeting later.
View more presentations from egonw.
<rule name="ReplaceMoleculeWithIMolecule"
language="java"
message="Use the IMolecule interfaces instead of the Molecule implementation"
class="net.sourceforge.pmd.rules.XPathRule">
<description>
Programming against the CDK interfaces allows users to pick their favorite
implementation (nonotify, datadebug).
</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//Type/ReferenceType/ClassOrInterfaceType[@Image='Molecule']
]]>
</value>
</property>
</properties>
<example>
<![CDATA[
Molecule mol = builder.newInstance(IMolecule.class);
]]>
</example>
</rule>
Patch pending...
try {
molecule = (IMolecule) container.clone();
} catch (CloneNotSupportedException e) {
throw new CDKException(
"Error occured during clone " + e
)
}
However, there are two small improvements that can be applied to this code. The first is that the the error message passed to the CDKException constructor can reuse the message of the cause Exception. The second improvement is that we can actually pass the cause exception is cause to the CDKException. Therefore, the CDKException can be constructed as (also fixing the typo :):new CDKException( "Error occurred during clone " + e.getMessage(), e );Oh, and, of course, CDK code should use variables of at least three characters. Now, the original CDKException construction was on one line, in total having four points of improvement :)
IChemObjectBuilder builder = new DefaultChemObjectBuilder(); IMolecule molecule = builder.newMolecule(); IAtom atom = builder.newAtom(); molecule.addAtom(atom);If your method actually has an IChemObject as input, it can retrieve the builder from there:
public IMolecule addToMolecule(IAtom atom) {
IChemObjectBuilder builder = atom.getBuilder();
IMolecule molecule = builder.newMolecule();
molecule.addAtom(atom);
}This latter situation is what exists most in the CDK library, actually. In some cases, this is not the case, and sometimes you may need to pass an IChemObjectBuilder to a constructor. This is, for example, the case with the constructor of the SmilesParser.



Now, this page on GitHub does not provide the means to leave comments; instead, you comment on commits.
This link will lead us to a page with a new column on the left side showing commit hashes, name of the commit author, and the first few characters of the commit message. For example, the web page bits relevant to code we want to comment on, looks like:
This shows us that commit 3ce78ba5 is the one we are interested in:
Clicking that blue comment icon, you get a dialog where you can enter your comment:
The 'Add Line Note' button confirms and saves your comment:
But it would certainly not hurt of you filed a bug report or sent an email.
So, using wedges leaves plenty of room for incorrectly specifying the stereochemistry. Therefore, we decided to go for SMILES, even though Noel recently showed that processing stereochemistry in SMILES is not trivial either. The SMILES I am currently using: