编码风格调查 [英] Coding style survey

查看:44
本文介绍了编码风格调查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你觉得哪个最好?


1.

a)输入* p;

b)输入* p;


2.

a)return(var);

b)return(var);

c )return var;


3.

a)return(ptr-> var);

b)return(ptr-> ; var);

c)return ptr-> var;


4.

a)return(foo(ptr-> ; var));

b)return(foo(ptr-> var));

c)return foo(ptr-> var);


5.

a)a =(b + c);

b)a =(b + c);

c)a = b + c;

d)a = b + c;


6.

a)

类型foo(类型arg1,类型arg2,...){

声明;

代码;

返回;

}

b)

类型为foo(类型为arg1,类型为arg2,...){

声明;


代码;


返回;

}

c)

类型foo(类型arg1,类型arg2,...)

{

声明;

c ode;

返回;

}

d)

类型foo(输入arg1,输入arg2,... )

{

声明;


代码;


返回;

}

e)

类型foo(输入arg1,输入arg2,...)

{

声明;

代码;

返回;

}

f)

类型foo(类型arg1,类型arg2,...)

{

声明;


代码;


返回;

}

Which do you think is best?

1.
a) type* p;
b) type *p;

2.
a) return (var);
b) return(var);
c) return var;

3.
a) return (ptr->var);
b) return(ptr->var);
c) return ptr->var;

4.
a) return (foo(ptr->var));
b) return(foo(ptr->var));
c) return foo(ptr->var);

5.
a) a = (b+c);
b) a=(b+c);
c) a = b+c;
d) a=b+c;

6.
a)
type foo(type arg1, type arg2, ...) {
declarations;
code;
return;
}
b)
type foo(type arg1, type arg2, ...) {
declarations;

code;

return;
}
c)
type foo(type arg1, type arg2, ...)
{
declarations;
code;
return;
}
d)
type foo(type arg1, type arg2, ...)
{
declarations;

code;

return;
}
e)
type foo(type arg1, type arg2, ...)
{
declarations;
code;
return;
}
f)
type foo(type arg1, type arg2, ...)
{
declarations;

code;

return;
}

推荐答案

在文章< bv***********@ulysses.noc.ntua.gr>,

Papadopoulos Giannis< ip ****** @ inf.uth.gr>写道:
In article <bv***********@ulysses.noc.ntua.gr>,
Papadopoulos Giannis <ip******@inf.uth.gr> wrote:
你觉得哪个最好?

a)输入* p;
b)输入* p ;


这取决于具体情况。什么是重要的对象:指针

p,或者指向* p的对象?偶尔你会看到像


char * * p;


这意味着p指向一个char-pointer。

2.
a)return(var);
b)return(var);
c)return var;


c

3.
a)return(ptr-> var);
b)return(ptr-> var );
c)返回ptr-> var;


相同

4.
a)return(foo(ptr-> var));
b)return(foo) (ptr-> var));
c)return foo(ptr-> var);


相同,但它应该是foo(ptr-> var)

5.
a)a =(b + c);
b)a =(b + c);
c)a = b + c;
d)a = b + c;


以上都不是。 a = b + c;

6.
a)
输入foo(输入arg1,输入arg2,...){
声明;
代码;
返回;
}
b)
输入foo(输入arg1,输入arg2,...){
声明;
代码;

返回;
}
c)
输入foo(输入arg1,输入arg2,......)
{
声明;
代码;
返回;
}
d)
输入foo(输入arg1,输入arg2,...)
{
声明;

代码;

返回;
}
e)
输入foo(输入arg1,输入arg2,... )
{
声明;
代码;
返回;
}
f)
输入foo(类型为arg1,类型为arg2,.. 。)
{
声明;

代码;

返回;
}
Which do you think is best?

1.
a) type* p;
b) type *p;
It depends on the situation. What is the important object: The pointer
p, or the object pointed to *p ? Occasionally you will see things like

char* *p;

which means that p points to a char-pointer.
2.
a) return (var);
b) return(var);
c) return var;
c
3.
a) return (ptr->var);
b) return(ptr->var);
c) return ptr->var;
Same
4.
a) return (foo(ptr->var));
b) return(foo(ptr->var));
c) return foo(ptr->var);
Same, but it should be foo (ptr->var)
5.
a) a = (b+c);
b) a=(b+c);
c) a = b+c;
d) a=b+c;
None of the above. a = b + c;
6.
a)
type foo(type arg1, type arg2, ...) {
declarations;
code;
return;
}
b)
type foo(type arg1, type arg2, ...) {
declarations;

code;

return;
}
c)
type foo(type arg1, type arg2, ...)
{
declarations;
code;
return;
}
d)
type foo(type arg1, type arg2, ...)
{
declarations;

code;

return;
}
e)
type foo(type arg1, type arg2, ...)
{
declarations;
code;
return;
}
f)
type foo(type arg1, type arg2, ...)
{
declarations;

code;

return;
}




以上都不是。 (b)在声明之前用空行。



None of the above. (b) with an empty line before declarations.


这是个人喜好的问题。


如果有人不这样做不喜欢你的方式,让他们

写一个漂亮的打印机重新格式化它。


如果您所在的公司有任何

的标准,请遵守他们的标准。它与代码的正确性无关,而且可能对将来如何维护代码产生影响



Papadopoulos Giannis写道:
It''s a matter of personal preference.

If someone doesn''t like the way you do it, let them
write a "pretty printer" to reformat it.

If the company you are working for has a standard for any of
these, comply with their standard. It has nothing to do
with the correctness of the code, but may have impact
on how the code will be maintained in the future.

Papadopoulos Giannis wrote:
您认为哪个最好?

1.
a)输入* p;
b)输入* p;

2.
a)return(var);
b)return(var);
c)return var;

3.
a)返回(ptr-> var);
b)return(ptr-> var);
c)return ptr-> var;

4.
a)return(foo(ptr-> var));
b)return(foo(ptr-> var));
var);

5.
a)a =(b + c);
b)a =(b + c );;
c)a = b + c;
d)a = b + c;

6.
a)
类型foo(类型arg1,输入arg2,...){
声明;
代码;
返回;
}
b)
输入foo(类型为arg1,类型arg2,...){
声明;

代码;

返回;
}
c)
类型foo (输入ar g1,输入arg2,...)
{
声明;
代码;
返回;
}
d)
类型foo(输入arg1,输入arg2,...)
{
声明;

代码;

返回;
}
e)
输入foo(输入arg1,输入arg2,......)
{
声明;
代码;
返回;
} f)
输入foo(输入arg1,输入arg2,......)
{
声明;

代码;

返回;
}
Which do you think is best?

1.
a) type* p;
b) type *p;

2.
a) return (var);
b) return(var);
c) return var;

3.
a) return (ptr->var);
b) return(ptr->var);
c) return ptr->var;

4.
a) return (foo(ptr->var));
b) return(foo(ptr->var));
c) return foo(ptr->var);

5.
a) a = (b+c);
b) a=(b+c);
c) a = b+c;
d) a=b+c;

6.
a)
type foo(type arg1, type arg2, ...) {
declarations;
code;
return;
}
b)
type foo(type arg1, type arg2, ...) {
declarations;

code;

return;
}
c)
type foo(type arg1, type arg2, ...)
{
declarations;
code;
return;
}
d)
type foo(type arg1, type arg2, ...)
{
declarations;

code;

return;
}
e)
type foo(type arg1, type arg2, ...)
{
declarations;
code;
return;
}
f)
type foo(type arg1, type arg2, ...)
{
declarations;

code;

return;
}




-

不可能做任何万无一失的事,因为傻瓜是这样的

ingenious - A. Bloch



--
"It is impossible to make anything foolproof because fools are so
ingenious" - A. Bloch


Nick Landsberg写道:
Nick Landsberg wrote:
这是个人喜好的问题。如果有人不喜欢你这样做的方式,那就让他们写一个漂亮的打印机吧。重新格式化。

如果您所在的公司有任何标准,请遵守他们的标准。它与代码的正确性无关,但可能对将来如何维护代码产生影响。
It''s a matter of personal preference.

If someone doesn''t like the way you do it, let them
write a "pretty printer" to reformat it.

If the company you are working for has a standard for any of
these, comply with their standard. It has nothing to do
with the correctness of the code, but may have impact
on how the code will be maintained in the future.




我知道..我已经有了我的风格(这有点特别)...

我只是想知道其他c程序员的代码(专家或
$ b) $ b新手)......



I know.. I have already my style (which is by the way a bit peculiar)..
I just wanted to know how other c programmers code (either experts or
novice)...


这篇关于编码风格调查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆