问题标签 [code-standards]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
552 浏览

java - 来自官方来源的最新一期 Java 样式指南/编码标准

我正在做一个处于初始阶段的项目,我正在制定一些编码标准和风格指南。我一直在为 Java 开发的一般编码标准、样式指南和最佳实践寻找一些好的资源。

我遇到了 Oracle 的官方编码约定,但它们似乎是从 1999 年开始的,所以我想知道是否有更新的东西。

FWIW,这是我找到的 Oracle 文档的链接: http ://www.oracle.com/technetwork/java/codeconv-138413.html

0 投票
2 回答
261 浏览

objective-c - 我应该如何在 camelCase 中用破折号写单词?

例如:元信息

metaInfornation,metainformationmetainfo?

getMetainfo,getMetaInfogetMetaInformation?

Objective-C风格呢?

0 投票
1 回答
1356 浏览

assembly - x86 汇编程序是否有任何编码标准?

我正在寻找类似 MISRA 或 HICPP 的东西,但要寻找汇编语言。我们公司有各种各样的风格和安全规则,我想每个编码社区都有自己的一套有用的习惯。但是有没有任何行业范围的标准?

0 投票
3 回答
199 浏览

c - 什么是反对 C 代码中的变量冗余的有力论据

我从事安全关键应用程序开发工作。最近,作为一名代码审查员,我抱怨如下所示的编码风格,但无法提出强有力的反对意见。那么反对这种变量冗余/重复的好论据是什么,我正在寻找可能导致问题或可能失败的测试用例的案例,而不仅仅是编码风格。

0 投票
1 回答
3470 浏览

matlab - Modern MATLAB codestyle: what is missing?

I seek to adopt a coding standard for MATLAB, but I am not sure if I picked the right one.

To my best knowledge there is not that much available on topic of programming guidelines for MATLAB, other than this document. The document is well written and has good feedbacks. Standard was published in 2002 (on matlab central) by Richard Johnson but has not being updated since. Is there a more up to date version of it or similar document? (I really failed to google up something else).

Background motivation assumes

  • Coding standards are important
  • Although MATLAB has not change much since 2002, other languages and their approaches have. One could really benefit from those practices.
  • The fact is a lot of people are writing new code using MATLAB or Octave. Although, one would argue the language is virtually dead (blah blah). I would rather not go there (let's mark it as an offtopic).

Why the codestyle is not good enough for me

I'd like to summarize here a few things. If you take time to read the document you might find that it

  • tries to be too hungarian (it's cryptic and I really hate this in most cases)
  • it has too many shortcuts (more less similar to the previous point)
  • it is not supported by Mathworks (but it actually might be a good thing, since all the good stuff in MATLAB came from the user community IMO)
  • there is no automated quality control tools respecting such coding style (here I mean not something like mlint as in *lint family, but more like pep8.py for python)

I guess the reason why such a tool has not been developed is actually the absence of a widely accepted coding standard.

I would really appreciate any of your criticism on the standard or information about a better one.

Do you have any experience on working with this standard? Which parts of it did not work for you? If you never used a formal coding standard but do have a valuable practice that does not fit into it - please provide an example.

0 投票
1 回答
3509 浏览

php - 具有与 Checkstyle 兼容的输出格式的最佳 PHP 代码样式检查器

我正在配置 CI 服务器并希望添加代码样式检查步骤来构建步骤序列。我的 CI 服务器是 TeamCity,因此代码样式检查步骤必须生成与代码样式格式兼容的 XML 输出。我发现很少有用于 PHP 代码样式检查的工具,我很困惑应该使用哪一个。

0 投票
4 回答
1076 浏览

php - 如何在 PHP 和 HTML 中添加注释

我有一段这样的代码。如何添加评论?它具有 HTML 和 PHP 组合代码。

0 投票
9 回答
17042 浏览

javascript - $('document').ready 情况下的 jQuery 最佳实践

我正在研究 jQuery 最佳实践,发现Greg Franko 的这篇文章

通常,我会:

但文章建议使用:

我可以看到那里的评论,但我无法弄清楚它到底在说什么。

那么,哪种方法更好,为什么?

我知道这两种方法都可以,但是第二种方法如何变得更好

0 投票
3 回答
498 浏览

php - PHP(Nette框架)自动编码标准检查

我想对 PHP Nette 框架的编码标准进行某种类型的自动检查,有这样的东西吗?EclipseNetbeans的独立应用程序或插件...例如,要检查 Java 代码,我使用Checkstyle。或者 Checkstyle 也可以检查 Nette 吗?

0 投票
1 回答
2087 浏览

node.js - How to check node.js code to code standards

Does anybody know how to check nodejs code to code standards automatically? I'm looking for some features like codesniffer but for node.js (express framework).