今日推薦開源項目:《Linux Command》
今日推薦英文原文:《56 Funny Code Comments That People Actually Wrote》
今日推薦開源項目:《Linux Command》傳送門:項目鏈接
推薦理由:該項目現在搜集了 570 多個 Linux 命令,是一個非盈利性的倉庫,並包括 Web 版本、Chorme 插件、Alfred版本等等,是非常值得收藏的 Linux 命令速查手冊。
今日推薦英文原文:《56 Funny Code Comments That People Actually Wrote》作者:Nehal Khan
原文鏈接:https://medium.com/better-programming/56-funny-code-comments-that-people-actually-wrote-6074215ab387
推薦理由:程序員迷惑行為大賞。
56 Funny Code Comments That People Actually Wrote
These are actually in a code base somewhere
Code comments are a human-readable explanation of what a computer program does. They are added to make the code easier for humans to understand.Well, in this article, you will see how code commenting can be funny, too. Here is a list of comments that were actually written in the code.
1.
/*
* Dear Maintainer
*
* Once you are done trying to 『optimize』 this routine,
* and you have realized what a terrible mistake that was,
* please increment the following counter as a warning
* to the next guy.
*
* total_hours_wasted_here = 73
*
2.
Exception up = new Exception("Something is really wrong.");
throw up; //ha ha
3.
// When I wrote this, only God and I understood what I was doing
// Now, God only knows
4.
// sometimes I believe compiler ignores all my comments
5.
// I dedicate all this code, all my work, to my wife, Darlene,
// who will have to support me and our three children and
// the dog once it gets released into the public.
6.
// drunk, fix later
7.
// Magic. Do not touch.
8.
// I'm sorry.
9.
return 1; # returns 1
10.
Catch (Exception e) {
//who cares?
}
11.
/**
* Always returns true.
*/
public boolean isAvailable() {
return false;
}
12.
/*
* You may think you know what the following code does.
* But you dont. Trust me.
* Fiddle with it, and youll spend many a sleepless
* night cursing the moment you thought youd be clever
* enough to "optimize" the code below.
* Now close this file and go play with something else.
*/
13.
try {
} finally { // should never happen
}
14.
const int TEN=10; // As if the value of 10 will fluctuate...
15.
// This code sucks, you know it and I know it.
// Move on and call me an idiot later.
16.
// If this comment is removed the program will blow up
17.
// I am not responsible of this code.
// They made me write it, against my will.
18.
/* Please work */
19.
// no comments for you
// it was hard to write
// so it should be hard to read
20.
options.BatchSize = 300; //Madness? THIS IS SPARTA!
21.
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it
22.
// Peter wrote this, nobody knows what it does, don't change it!
23.
/** Logger */
private Logger logger = Logger.getLogger();
24.
// I have to find a better job
25.
// Real programmers don』t comment their code.
// If it was hard to write,
// it should be hard to understand.
26.
// This is black magic
// from
// *Some stackoverlow link
// Don』t play with magic, it can BITE.
27.
// For the sins I am about to commit, may James Gosling forgive me
28.
// Comment this later
29.
// Remove this if you wanna be fired
30.
}catch(Exception ex){
// Houston, we have a problem
}
31.
// I can』t divide with zero, so I have to divide with something very similar
result = number / 0.00000000000001.
32.
int getRandomNumber()
{
Return 4; // chosen by fair dice roll.
// guaranteed to be random.
}
33.
#TODO: Figure out what I』m doing here and comment accordingly.
34.
// If this code is still being used when it stops working, then
// you have my permission to shoot me. Oh, you won't be able
// to - I'll be dead...
35.
// If you are reading this, that means you have been put in charge of my previous project.
// I am sorry, so sorry for you. Godspeed.
36.
// I wrote this while drunk, I don』t know what it does,
// but if you remove it the program breaks.
37.
// This code worked before, but my cat decided to take a
// trip across my keyboard...
38.
long long ago; /* in a galaxy far far away */
39.
long john; // silver
40.
#define TRUE FALSE // Happy debugging suckers
41.
// Dear future me. Please forgive me.
// I can't even begin to express how sorry I am.
42.
// private instance variable for storing age
public static int age;
43.
// I am not sure why this works but it fixes the problem.
44.
last = first; /* Biblical reference */
45.
try {
} catch (SQLException ex) {
// Basically, without saying too much, you're screwed. Royally and totally.
} catch(Exception ex)
{
//If you thought you were screwed before, boy have I news for you!!!
}
46.
// John! If you'll svn remove this once more,
// I'll shut you, for God's sake!
// That piece of code is not "something strange"!
// That is THE AUTH VALIDATION.
47.
long time; /* know C */
48.
// Abandon all hope ye who enter beyond this point
49.
/* Ah ah ah! You'll never understand why this one works. */
50.
catch (Ex as Exception) {
// oh crap, we should do something.
}
51.
// TODO make this work
52.
// If you're reading this, then my program is probably a success
53.
// set break point here - you'll never reach it
54.
/*
** The author disclaims copyright to this source code.
** In place of a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
*/
55.
// I'm not sure what I did
56.
// This is crap code but it's 3 a.m. and I need to get this working.
References
Best code comments on stackoverflow.com Funniest code comments on quora.com Best comments on loudprogrammer.net Funny code comments on hostingpill.com Funny code comments on blogspot.com下載開源日報APP:https://openingsource.org/2579/
加入我們:https://openingsource.org/about/join/
關注我們:https://openingsource.org/about/love/