Developer Review¶
Part to copy for push to Dev QA
Migrations (No duplicate numbers, class names) -
Code Indentation and Style (2 spaces + formatted) -
Naming (meaningfull method names, ! ?) -
Structure and Length (no long methods, light controllers, repeated code)-
Javascript Checks (JSLint, Global, Namespacing) -
Unit Tests -
HTML and CSS (IE6, IE7, FF)-
SQL (ansi, capitals, indentation) -
Checklist¶
1. Style
Have you followed the coding style guide for all of your javascript, html, css, js and ruby?
2. Naming
Do your method names and attribute names convey meaning?
If a method alters or modifies something you should consider ending the method with ! remove_all_units!
if it's a method that returns true or false it should end with a question mark is_allowed?
3. Structure and length
Have you got long methods, do they need to be separated out into smaller easy to manage chunks?
Have you moved methods up to models where possible?
Are there repeated chunks that should be refactored into a single function?
4. Comments for hard or odd bits
Have you done something weird that's going to confuse one of the other coders, put in quick comments to explain why.
Are your comments in english? Does the english make sense or do you need to get it checked?
5. Javascript
Have you run your code and passed through JSLint?
Have you ensured that your not polluting the global namespace.
Are your functions in namespaced appropriately (i.e. the order me a coffee functions are all in SomeNamespace.CoffeeOrdering = {}
Are all of your function names in camel case?
6. Unit tests
Does your code have sufficient unit test coverage where appropriate?
7. HTML / CSS
Does it work and look good in IE6 / IE7 /FF / Safari (Where possible and necessary to test)
Ensure that there are no inline styles (unless absolutely necessary)
Is your html formatted
8. SQL
Are all of your sql statements in capital letters?
9. Ansi Standard Joins
Have you used Ansi-Standard joins and ensured that your table joins are separated from your where clauses.
e.g.
The Code Style Guide¶
The developer review is to ensure high quality, maintainable readable code. Each developer should "review" the code themselves before submitting it, but it needs to cover the following aspects:
1. Code indentation and style.
Is the entire file you submitted neat, indented (2 spaces) and formatted correctly?
Ruby¶
Spacing
2 Spaces for every piece of indented code
Comments
Comments should the follow the styles in:
http://rdoc.sourceforge.net/doc/index.html
In short
# Calculates some_code by using bla and some other business rule
some_code = bla + 1
and
# Test to see if a new word contains the same
# letters as the original
def is_anagram?(text)
@initial_letters == letters_of(text)
end
If the functionality is not obvious, there needs to be a comment describing what it does in English. If you think your English is wrong, then you can just ask someone else to review it for you.
Spacing between functions
use
a = 1
not
a=1
Lining functions up
use
dog = 1
cattle = 2
something_else = 3
not
dog=1
cattle=2
something_else=3
Comments should use the rubydoc styles shown at
Javascript¶
Function calls should be:
this.foo(bar);
Not
this.foo (bar);
The space differentiates them from method invocations.
Control statements should be:
// space between if and parentheses
if (something == x) {
doSomethingElse();
} else { // else on same line as close and open braces
doSomethingNice();
}
//space between switch and parentheses
switch (x) {
case 'y' :
return 'something';
break;
case 'n' :
return 'somethingElse';
break;
}
//space between for and parentheses
for (var i=0; i<n; i++) {
...
}
Conditions and assignments should have spaces ( except maybe in for loop declarations
)
Use:
if (x == y) {
...
}
y = x;
Not
if (x==y) {
...
}
y=x;
HTML Formatting (2 spaces)¶
<div>
<ul>
<li><a href="bla.html">something</a></li>
</ul>
<p>Some Paragarph</p>
<p>Some other paragraph</p>
</div>
CSS Formatting (2 spaces)¶
#something {
border: 1px solid red;
color: green}
#something a {
font-weight: bold;}
#something div {
background-color: red;}
.some_other_class {
border: none;}
.some_other_class {
border: 1px solid blue;}
Javascript¶
The majority of javascript should be stored in separate files, which group functionality together. E.g. the functionality for a page.
The javascript should be namespaced and not pollute the global namaspace.
Only very small inline javascript should exist. E.g.
<% js do %>
Prohost.admin_page.init(<%= @init.to_json %>);
<% end %>
h2. SQL Formatting Note:
* Capital Letters for SQL keywords
* Line everything up
Instead of:
SELECT *
FROM table_a, table_b, table_c
WHERE table_a.id = table_b.foreign_key_id and
table_a.desc LIKE '%hello%' and
table_c.foreign_key_id = table_a.id (+)
Format it like this:
SELECT *
FROM table_a
JOIN table_b ON table_b.foreign_key_id = table_a.id
LEFT JOIN table_c ON table_c.foreign_key_id = table_a.id
WHERE table_a.desc LIKE '%hello%'
分享到:
相关推荐
Idea Code Style 配置 XML, 包含了Google和Alibaba的。
eclipse配置代码格式的codestyle.xml文件,在Eclipse或MyEclipse中点击Window -> Preferences菜单,点击左侧的“Java”->“Code Style”->Formatter中import即可
MyEclipse code style
eclipse开发android,代码标准...1、Preference->Java->Code Style->Formatter->Import->添加android-formatting.xml文件 2、Preference->Java->Code Style->Organize Imports->Import->添加android.importorder文件
Node.js编程-Sublime Code Style
提升java代码的可读行,规范行。该模板严格按照代码的缩进原则进行编写。 使用方法:1 在eclipse中选中一个工程,右键单击->propertys->java code style->formatter->import->导入该xml文件
代码规范及CodeStyle使用
Eclipse代码格式化CodeStyle和CheckStyle配置,含3个配置文件。导入后即可使用
Eclipse Code Formatter xml
android studio修改code style文件
eclipse 里 ctrl + shift + f的 Project — Properties - Java Code Style - Formatter
Google的Java编码规范 This document serves as the ...code in the Java™ Programming Language. A Java source file is described as being in Google Style if and only if it adheres to the rules herein.
压缩包中整理了CodeFormatter.xml和codetemplates.xml及配置文档
导入之后,仅需要改下tab的大小即可。
as格式化code
很好的一款代码检测规格文件,常见的代码书写bug或者不合理的地方都会提示,
IDEA的代码风格模板,华为标准 public DTO request(String reqMsg, String tradeInterface) { if (verifyResult.getResolveSuccess()) { if (bankSignEntity == null) { throw NoCardCommonException ...
NULL 博文链接:https://woshixushigang.iteye.com/blog/1326282
IDEA的Java格式化代码配置模板,设置之后只需要使用快捷键ctrl+alt+L即可一键格式化代码,非常的方便和快捷。
资源不能设置免费,如果没积分,请直接访问官网https://github.com/google/styleguide/blob/gh-pages/intellij-java-google-style.xml