In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "Android annotation case analysis", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Android annotation case analysis" bar!
I have been criticized many times for writing poor comments. I thought that if the function name was longer, the meaning was clearer, and the variables were easier to understand, there would be no need to write comments. As a result, when I gave an award to my code last year, I said that the comments were not standard, and each function had only a few lines, which I couldn't understand. Once a colleague asked me how much new code was added. I looked at the code statistics and found that it was not much, but suddenly noticed that the comment rate was 56%. That means 100 lines of code and 56 lines of comments. What a godlike code. This time I really "concentrated" on writing notes. Every function header is commented, and even the constructor is commented.
/ * function: constructor * input: none * output: no * author: xxxxxxxxxxx****/XXXXXXXXX:XXXXXXXX () {}
In this way, two lines of code, with six lines of comments, will get a high comment rate. But is this comment really useful? God-like comments include:
/ * Function name:*Param:*IN:*OUT:*Reference by:*Called by:*Return:History:*Author:*Date:*/
When I first entered the company, I sent a 17-inch LCD, and a code had to scroll a lot of screens to finish it. These comments are all made by a plug-in of Source Insight, which is quite bossy. But many comments are made entirely for the sake of comments, and there is no useful information. Every time I see this kind of comment, I have an impulse to kill it. Some time ago, the new employee code review was said by the software manager that the comments were not complete, saying that these should be made up. Fortunately, I saw it at that time, and she was mechanically filling up the Reference by notes. I stopped it immediately and gave her a copy of my notes.
/ * * function: parameter: return value: author: * /
And, if you don't have the information, don't fill it in. If the return value is void, this line is killed. I think notes really need to write something meaningful, something that is not easy to change, something important. For example, what function name is written to do, isn't there immediately? Constructors and destructors, if not with parameters, are not recommended. Who doesn't know this is a constructor? There is also a special note. If you open the ROM build.prop file of Huawei's G330 phone, you will see this magical comment:
Persist.fuse_sdcard=false#DTS2012011902027 guanjunujie 20120120 beginro.config.hw_allowformat=true#DTS2012011902027 guanjunujie 20120120 end#DTS2012011902069 guanjunujie 20120120 beginro.config.hw_allow_ums_and_mtp=true#DTS2012011902069 guanjunujie 20120120 end#DTS2012021607935 guanjunujie 20120214 beginro.config.switchPrimaryVolume=true#DTS2012021607935 guanjunujie 20120214 end# DTS2012022802590 wuye00193878 20120229 beginro.config.internal_sdcard=yesro.config.hw_cdma_cdg=false# DTS2012022802590 wuye00193878 20120229 end#/*
< DTS2012031303262 yufei 20120313 begin */#/*< DTS2012022306777 yufei 20120301 begin */ #/*DTS2012022306777 yufei 20120301 end >* / # / * DTS2012031303262 yufei 20120313 end > * / # / * * DTS2012030302649 tiandazhang 20120303 end > * / # / * DTS2012031100199 tiandazhang 20120311 end > * / # DTS2012030300592 Cheng Wei c81003953 2012-03-09 add begin.ro.build.characteristics=default#DTS2012030300592 Cheng Wei c81003953 2012-03-09 add end.#DTS2012022804910 chensaitao 20120323 beginro.config.hw_test_version=false#DTS2012022804910 chensaitao 20120323 end# DTS2012062806152 z81003396 20120628 Delete ro.huawei.cust.drm.fl_only=true.#/**/ # DTS2012032607960 tiandazhang 20120327 beginro.config.widevine_level3=true# DTS2012032607960 tiandazhang 20120327 end#/**/# DTS2012041703860 zhangqijia 20120417 begin# DTS2012080800950 baitao 20120905 beginro.com.google.gmsversion=ics_signed_r4# DTS2012080800950 baitao 20120905 end# DTS2012041703860 zhangqijia 20120417 end#DTS2012022002232 wangwenbo 20120220 beginro.config.hwft_simrefresh=true#DTS2012022002232 wangwenbo 20120220 end
When I was transplanting 4.1 at that time, I was dizzy by these "notes". Don't you think these are all heavenly books? They try to show a period of history instead of version management software.
In some of our old code, there are a lot of similar comments, several begin in succession, then I don't know where the end is, and then a line of code is surrounded by several begin. People who read the code keep scrolling. When I was a new employee, I asked, why are you doing this? Why would you do that? Be more convenient when you are told to code.
Later, when I actually used IBM's Clearcase, I knew why it was "more convenient". Clearcase, at least in version 7.x, still doesn't have a concept of meta commit. It can only generate one node per file, and for each commit, it will form multiple nodes for different files. Each commit, in fact, is the commit of several files, there is no relationship between them. So once you are on the library, you want to know how a problem is modified. If you just look at one file, you can't find changes to other files! But SVN,GIT these, each commit is a complete collection, then these problems do not exist. Therefore, under such old-fashioned version management software, we can only take similar comments in an attempt to find all the changes quickly. Especially when CMO merges the problem list!
But this is really quite unsafe. So what I do is, I post all my changes in the problem list, but don't comment in the code, you want to merge the questions, look at my problem list, understand it, and then merge it. In case there is no complete pair of my begin end, it will be blamed on me.
Thank you for your reading, the above is the content of "Android annotation example analysis", after the study of this article, I believe you have a deeper understanding of the problem of Android annotation example analysis, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.