Topic: [个人原创]如何高效使用代码注释符号

  Print this page

1.[个人原创]如何高效使用代码注释符号 Copy to clipboard
Posted by: jerryjerry123
Posted on: 2005-04-13 13:48

Java中基本的代码注释符号有// 和 /* */
我在实际项目中发现我们其实可以合并两者使用.
如下:[color=blue][/color]
/*
Here is the code
//*/
当我们要使用这块代码时, 只要将第一行的/*改为//*, 即加一个/

希望我这个个人技巧对大家有用

2.Re:[个人原创]如何高效使用代码注释符号 [Re: jerryjerry123] Copy to clipboard
Posted by: littledeer1974
Posted on: 2005-04-15 19:03

我怎么没有想到,好

3.Re:[个人原创]如何高效使用代码注释符号 [Re: jerryjerry123] Copy to clipboard
Posted by: forlch
Posted on: 2005-04-16 16:07

好方法。呵呵。谢了。

4.Re:[个人原创]如何高效使用代码注释符号 [Re: jerryjerry123] Copy to clipboard
Posted by: zsky
Posted on: 2005-06-23 14:50

哈哈,果然很有技巧啊,学习了

5.Re:[个人原创]如何高效使用代码注释符号 [Re: jerryjerry123] Copy to clipboard
Posted by: hongxin
Posted on: 2005-07-12 13:33

学习了!

6.Re:[个人原创]如何高效使用代码注释符号 [Re: jerryjerry123] Copy to clipboard
Posted by: ranchgirl
Posted on: 2005-07-15 14:45

Great suggestion!

I used a little similar strategy plus ant token replacement in copy task, made our game code comment and uncomment out Chinese/English/etc by just needing to change one user defined ant property
lang=en
lang=cn
lang=any other supported languages such as Spanish, etc.


/* @cn.comment.start@
String abc="代码";
@cn.comment.end@ */

/* @en.comment.start@
String abc="Source code";
@en.comment.end@ */

// More languages here.


When lang=en, or English
"@en.comment.start@" is replaced by "*/".
"@en.comment.end@" is replaced by "/*"


The cn, Chinese code and all other language code is untouched or still commented out.

Advantages
1) When we copy the code to the place for build (compile), the replacement is done automatically by ant copy task. Build games in different languages became as easy as switching one word in the build.properties.

2) One more thing is wonderful here. It is way better than use "if else or switch case statements". since the byte code is much smaller. It is especially important when you are building games on mobile devices.

3) We only need one code base instead of many, which made code maintenance a lot simpler, less headache!!!

You need to use apache ANT to do your build and deployment.

http://ant.apache.org

I hope this strategy might be useful for someone here!

---GongShi

7.Re:[个人原创]如何高效使用代码注释符号 [Re: jerryjerry123] Copy to clipboard
Posted by: ranchgirl
Posted on: 2005-07-15 15:00

The above is 100% [个人原创], my invention, hehe! Smile


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923