Refactored code using some boolean convenience functions to improve code...

... readability.

I'll add a second patch containing only reformatting once this patch has been accepted, to clean up the formatting problems encountered on the previous patch.
I expected that - I split the test from one into two so that I could apply one of my methods, and to disentangle what was going on in the if-statement. Now that I've figured it out, I'll probably recombine these two ifs.


From: John May 
Sent: Tuesday, September 02, 2014 8:11 PM
To: cdk/cdk 
Cc: mbv31602 
Subject: Re: [cdk] Refactored code using some boolean convenience functions to improve code... (#57)


In tool/builder3d/src/main/java/org/openscience/cdk/modeling/builder3d/AtomPlacer3D.java:

> -					try{
> -						if (getDoubleBondConfiguration2D( molecule.getBond(molecule.getAtom(first_atoms[counter-1]),molecule.getAtom(first_atoms[counter-2])),
> -										(molecule.getAtom(first_atoms[counter])).getPoint2d(),(molecule.getAtom(first_atoms[counter-1])).getPoint2d(),
> -										(molecule.getAtom(first_atoms[counter-2])).getPoint2d(),(molecule.getAtom(first_atoms[counter-3])).getPoint2d())
> -							==5){
> -							dihedrals[counter] = DIHEDRAL_BRANCHED_CHAIN;
> -						}else{ dihedrals[counter] = DIHEDRAL_EXTENDED_CHAIN;}
> -					}catch(CDKException ex1){
> -						dihedrals[counter] = DIHEDRAL_EXTENDED_CHAIN;
> -					}
> -				} else {
> -					dihedrals[counter] = -1;
> -				}
> -				counter++;
> +			if (isHeavyAtom(chain.getAtom(i))) {
> +                if (!chain.getAtom(i).getFlag(CDKConstants.VISITED)) {
Okay - but PMD warns on

if(bool){
  if(bool){
  } // no else
}
—
Reply to this email directly or view it on GitHub.