`
wuut
  • 浏览: 1922 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

Jmol Coding Standard

    博客分类:
  • Java
 
阅读更多

Jmol Coding Standard

Professional software developers know that it is important to maintain a consistent coding style. Having a consistent style with regular idioms makes it easier to spot problems.

More importantly, it allows you to read the code without distractions.

It is particularly important on group projects where more than one person is looking at the. Understanding code is difficult enough , without throwing-in lots of distractions caused by inconsistent punctuation and indentation.

Everyone agrees that it is demonstrably better to have a consistent coding style within a project. This far outweighs any personal preferences that an individual may have.

When you write Linux kernel code you use one style. When you write Jmol code you use another.

  • Your text editor should indent and reindent automatically for you. If you don't know how to enable this feature in your text editor then learn how to enable it. If your text editor cannot do this then get another text editor.
  • Indentation level should be two spaces.
class Foo {
  int someClassVariable;

  Foo(int evenOrOdd) {
    someClassVariable = 99;
  }

  ...
}
  • Space characters should be used instead of tabs.
  • Assignment and arithmetic operators generally contain spaces on both sides.
a = b + c;
  • You are allowed to eliminate the spaces within expressions in order to make operator precedence more clear.
int cSquared = a*a + b*b;
  • Spaces follow commas in argument lists.
foo(a, 3.14159, "jmol");
  • Lines should be no more than 80 characters wide.
  • Break lines inside argument lists so that the parameters line up vertically.
  foo(longParameter1,
      longParameter2,
      param3, param4);
  • Generally, expressions that must be broken should finish each line with an operator. Parentheses may also be desired in these cases.
  a = (b +
       c + d);
  • Open brace goes on the line that starts the block. Close brace goes on a line by itself.
  if (condition) {
    ...
  } else {
    ...
  }

  while (condition) {
    ...
  }
  • In cases of very simple if statements or cascading else/if statements then the following is an acceptable format that does not introduce an unnecessary amount of white space:
if ( )
  { xxx; }
else if
  { xxx; }

OR

if ( ) { xxx; yyy; }
  • Loop indexes start at 0, not 1. A loop index starting at 1 deserves an explanatory comment.
  • In general, for loops should look like
  for (int i = count; --i >= 0; ) {
    ...
  }

  for (int i = 0; i < count; ++i) {
    ... 
  }
  • The only valid comparison operators for loop termination are < and >= ... anything else is probably a bug. If you are really sure that it is not a bug then put a comment in the code.
  • Use long descriptive variable names and method names. Do not be afraid of typing.
  • Line-by-line comments within the code are discouraged ... except in very special circumstances. If you put in lots of comments like this then you may find them deleted.
  • If you feel obligated to insert comments put them as javadoc before the function body.
  • If your code is changing then do not put in comments. Bad/outdated comments are worse than no comments.
  • You may want to look at The Elements of Java Style by Vermeulen, et al.
分享到:
评论

相关推荐

    jmol软件完整版

    Jmol是一款开源的Java分子查看器,主要用于三维分子模型的展示和分析,尤其在化学、生物化学、药物研发以及教育领域有着广泛的应用。这个“jmol软件完整版”压缩包包含的是Jmol的特定版本——12.1.30,意味着它可能...

    Jmol-13.0.6

    Jmol-13.0.6 是一个专用于化学结构可视化的重要工具,它以其强大的功能和易用性在科学界广受欢迎。Jmol 不仅能够显示分子的三维图像,还能帮助用户深入理解复杂的化学结构,这在教育、研究以及药物发现等领域具有...

    JMol Plugins-开源

    项目“plugin4jmol”被认为支持扩展 JMol 工具的插件的开发。

    JSmol:Jmol的基于JavaScript的Molecular Viewer-开源

    JSmol是基于Java的分子可视化小程序Jmol(jmol.sourceforge.net)的扩展,它是仅HTML5 JavaScript的Web应用程序。 当平台不支持Java小程序(iPhone / iPad)或不支持小程序(Android)时,可以将其与Java小程序结合...

    Jmol:三维化学结构的交互式查看器。-开源

    Jmol 可以读取多种文件类型,包括 PDB、CIF、SDF、MOL、PyMOL PSE 文件和 Spartan 文件,以及 Gaussian、GAMESS、MOPAC、VASP、CRYSTAL、CASTEP、QuantumEspresso、VMD 和许多其他量子化学的输出程式。 文件可以...

    Jmol Tutorial Creator++-crx插件

    jmol教程creator ++,或简短的JTC ++,修复了Milwaukee工程学院的Jmol教程创建者(https://cbm.mse .edu / markmyweb / jmolcreatorstonybrook /),如分子不加载。 它还添加了设置默认分子的整洁特征。 ---------...

    Jmol-SwingJS:与SwingJS兼容的JmolJSmol用于Java和JavaScript分子的可视化和分析

    **Jmol-SwingJS** 是一个专为Java和JavaScript环境设计的开源项目,它使得分子可视化和分析在这些平台间无缝对接成为可能。这个项目的主要目标是提供一个与SwingJS兼容的Jmol和JSmol实现,允许开发者在Java应用程序...

    jsmol-local:如何在网页上本地设置jsmol的示例

    JSmol基于Java Applet的Jmol,但移除了对Java的依赖,转而使用纯JavaScript实现。这使得它可以在各种现代浏览器中运行,无需安装任何额外的插件。JSmol的核心功能包括读取多种化学文件格式(如PDB、CIF、MOL等),...

    CaGe-source

    2. **j** 和 **Jmol.jar**:Jmol是一个开源的Java应用程序,用于查看和操作化学结构。这里可能是CaGe源代码的一部分,用于可视化生成的富勒烯结构,用户可以通过Jmol交互式地探索和分析分子模型。 3. **java**:...

    JMolDraw-开源

    《JMolDraw:开源二维化学结构图绘制程序详解》 在信息技术与科学研究的交融中,开源软件扮演着至关重要的角色,它们为用户提供了自由、灵活且成本低廉的工具。其中,“JMolDraw”是一个专为化学领域设计的开源软件...

    J-ICE-开源

    J-ICE,全称为“Jmol接口的晶体学和电子特性”,是一个基于开源分子可视化工具Jmol的扩展程序。它专为科学家和研究人员设计,尤其在晶体学和电子性质研究领域提供了强大的功能。J-ICE的核心是集成Jmol的强大可视化...

    论文研究-激光诱导光化学反应仿真可视化研究 .pdf

    激光诱导光化学反应仿真可视化研究,羊金花,白明泽,该文使用Java Applet、CGI、Gnuplot和Jmol等技术构建了激光诱导光化学反应的可视化系统PRVLAB,根据仿真模型的特点,PRVLAB采用面向对象技术��

    stuyproteomics.github.io

    "stuyproteomics.github.io" 是一个专为Stuyvesant社区设计的网站,它提供了Jmol的交互式展示,用于共享和探索常见的蛋白质结构。这个网站利用了开源技术,特别是JavaScript编程语言,使用户能够直观地理解复杂的...

    互联网上的矿物专业数据库和矿物信息资源平台.pdf

    除了传统的数据检索功能,现代矿物数据库还采用了Jmol和JPOWD Java控件,将抽象的结晶学基础知识通过三维虚拟现实技术形象展示出来,为矿物和晶体教学提供了很好的辅助作用。例如,“MineralogyDatabase”就使用了...

Global site tag (gtag.js) - Google Analytics