简体   繁体   English

Javascript,PHP,C和C ++的统一编码样式

[英]Unified coding style for Javascript, PHP, C, and C++

I'd like to have one coding style across multiple languages. 我想要一种跨多种语言的编码样式。 Can anyone provide a link to code that is styled nicely, that I can use for each language? 谁能提供我可以用于每种语言的样式精美的代码的链接?

It is easiest to just look at an example rather than read for the multitude of cases that arise. 仅查看示例而不是阅读出现的大量案例是最简单的。

There's not a chance in hell. 地狱中没有机会。 There's no such thing as code that's styled nicely for C and C++, let alone across the other languages too. 没有适合C和C ++的代码风格很好的东西,更不用说其他语言了。 You haven't exactly picked C# and Java here in terms of language similarities. 在语言相似性方面,您尚未完全选择C#和Java。

Edit: Do not, ever, use the Google Style Guide. 编辑:永远不要使用Google样式指南。 It is horrendous and terrible. 这是可怕的和可怕的。 It was only ever devised to make C++ compatible with C, which basically means not using virtually all of the useful language features and writing some terrible code. 它仅是为了使C ++与C兼容而设计的,这基本上意味着实际上不使用所有有用的语言功能并编写一些糟糕的代码。 And even then, you'd never make it compatible with JavaScript and PHP. 即使那样,您也永远不会使其与JavaScript和PHP兼容。

Javascript - Probably not compares with the others. Javascript-可能无法与其他比较。

Worth reading the coding styles from ESA wrt Java, C++. 值得阅读ESA wrt Java,C ++的编码样式。

Also getting documentation out of Doxygen is another good starting point. 同样,从Doxygen删除文档也是另一个很好的起点。

Wikipedia has an article that lists several C coding styles. Wikipedia 的文章列出了几种C编码样式。 Anything that works for C should work similarly for all the languages you ask for with little additional thinking. 任何适用于C的东西都应该对您要求的所有语言都类似地工作,而无需多加思考。

It's really a matter of taste. 这真的是一个品味问题。 There are no definite standards to follow in this case. 在这种情况下,没有明确的标准可遵循。

See the many questions on this subject: 请参阅有关此主题的许多问题:

And more. 和更多。 All you need to do is search :) 您需要做的就是搜索:)

I would suggest something like this, it seems the way most people are heading, at least on the non-microsoft side of things: 我建议这样的事情,似乎大多数人的前进方向,至少在非微软方面:

http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml

Although that is for C++, it also applies to the c-like languages you mention. 尽管这是针对C ++的,但它也适用于您提到的类似C的语言。 You can look at example code Google provides for other languages, it all tends to stick this this general style. 您可以看一下Google为其他语言提供的示例代码,这些代码通常都倾向于这种通用样式。 For instance the code within these pages: http://code.google.com/apis/maps/documentation/javascript/basics.html and http://code.google.com/apis/calendar/data/1.0/developers_guide_php.html 例如,以下页面中的代码: http : //code.google.com/apis/maps/documentation/javascript/basics.htmlhttp://code.google.com/apis/calendar/data/1.0/developers_guide_php。 html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM