TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

NASA C Style Guide [pdf]

99 点作者 walterkobayashi超过 8 年前

8 条评论

keithnz超过 8 年前
Looking at their example code.... I find there is a lot of problems, duplicated code, large function with many many obvious simpler functions inlined causing lots of local variable pollution.<p>MISRA is another standard that&#x27;s popular and I&#x27;ve seen a bunch of code developed using this standard.<p>But the problem with style guides, they have lots of points that are very agreeable, but it is all undone if you don&#x27;t have clean well designed code. I&#x27;ve seen too much emphasis on conforming to the style guide (often because of contractual agreements on the developed code). But the more important part of making the code clean gets less attention because it is harder to quantify and harder to enforce via static analysis.<p>however, that doesn&#x27;t mean it&#x27;s a bad thing to have, it&#x27;s just that conformity to a style guide is a very low bar in terms of quality.
评论 #12996310 未加载
评论 #12996323 未加载
thewisenerd超过 8 年前
How strictly do people writing code have to adhere to styling guides (not just in NASA, but everywhere else too)?<p>I get that coding standards are a good thing and plain-simply following these will produce &quot;readable&quot; and (possibly) maintainable code, but will that make the code any _better&#x2F;efficient_ ?<p>Though this does catch some &quot;gotchas&quot; in C, like the if-if-else and the #define trap, I wonder if the Code Review involves a guy rejecting my patches with the comments, &quot;you have missed out guideline 6.4.3.5 defined in page 54&quot;.
评论 #12997995 未加载
评论 #12996407 未加载
评论 #12997381 未加载
troycarlson超过 8 年前
I love seeing internal documents like this that are used at reputable companies. They&#x27;re both educational and a fun glimpse into how high-performing teams operate.
评论 #12996827 未加载
0xmohit超过 8 年前
<p><pre><code> *average=*total&#x2F;*count; &#x2F;* compute the average *&#x2F; ^ begin comment end comment^ </code></pre> The guide recommends a space after the `&#x2F;` operator. Does a pair of parenthesis (around the denominator) in such cases hurt that much?<p>--<p>As an aside, I&#x27;d be interested to see their NodeJS Style Guide too. Any pointers?
nickpsecurity超过 8 年前
Two others of theirs:<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=12014271" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=12014271</a><p><a href="http:&#x2F;&#x2F;spinroot.com&#x2F;gerard&#x2F;pdf&#x2F;P10.pdf" rel="nofollow">http:&#x2F;&#x2F;spinroot.com&#x2F;gerard&#x2F;pdf&#x2F;P10.pdf</a>
pmiller2超过 8 年前
I&#x27;m a little disturbed that this doesn&#x27;t make any mention of when C is even appropriate. I know if I were an astronaut, I&#x27;d be concerned about the code running on the vehicle I was on.
评论 #12996511 未加载
satysin超过 8 年前
4 space indentation and not tabs. What would Hendricks say?!
评论 #12995955 未加载
评论 #12995810 未加载
GnarfGnarf超过 8 年前
I see the brace goes on the next line, as it should:<p><pre><code> if(condition) { expression... } </code></pre> instead of the obfuscated form:<p><pre><code> if(condition) { expression... }</code></pre>
评论 #12996836 未加载
评论 #12996632 未加载
评论 #13004069 未加载
评论 #12996394 未加载
评论 #12996185 未加载