代码注释之程序猿天真可爱无国界!

2023-10-08 06:08

本文主要是介绍代码注释之程序猿天真可爱无国界!,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

无意间在 Stack Overflow上看到了这个有趣的讨论,标题为 “What is the best comment in source code you have ever encountered?”。发现国外的程序猿原来都是那么逗!原文包含的内容太多,就摘录了一些评价共鸣较多的跟大家分享。开始就读读英文的吧,如果喜欢的人多,我再整理翻译!
 /**
* For the brave souls who get this far: You are the chosen ones,
* the valiant knights of programming who toil away, without rest,
* fixing our most awful code. To you, true saviors, kings of men,
* I say this: never gonna give you up, never gonna let you down,
* never gonna run around and desert you. Never gonna make you cry,
* never gonna say goodbye. Never gonna tell a lie and hurt you.
*///I'M SORRY!!!! I just couldn't help myself.....!// I know the line below is wrong, but it came that way from our IP vendor, and 
// the driver won't work if you "fix" it. I've had to revert this change 4 times
// now. Leave it alone, or I will hunt you down and hurt you
if (r = 0) {/* bunch of code here */
}
else
{/* even more code here */
}// this comment included for the benefit of anyone grepping for swearwords: shit.// This comment is self explanatory.doRun.run();  // ... "a doo run run". // Dear maintainer:
// 
// Once you are done trying to 'optimize' this routine,
// and have realized what a terrible mistake that was,
// please increment the following counter as a warning
// to the next guy:
// 
// total_hours_wasted_here = 42
//// sometimes I believe compiler ignores all my commentsException up = new Exception(“Something is really wrong.”);
throw up; //ha ha//When I wrote this, only God and I understood what I was doing
//Now, God only knows// 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.// drunk, fix later// Magic. Do not touch.return 1; # returns 1double penetration; // ouch/// this is a well commented line// I am not sure if we need this, but too scared to delete.// I am not responsible of this code.
// They made me write it, against my will./* Please work *//* You are not meant to understand this *//* You should feel my soul */// This shouldn't happen. The only way this can happen is if the
// JFileChooser has returned a File that doesn't exist
// on the system. If this happens we can't recover, and there is more than likely
// a rip in the space time continuum that the user is too distracted by to notice
// anything else.//Dear future me. Please forgive me.
//I can’t even begin to express how sorry I am.options.BatchSize = 300; //Madness? THIS IS SPARTA!// I have to find a better job// hack for ie browser (assuming that ie is a browser)} catch (PartInitException pie) {
// Mmm… pie
}// 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.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!!!
}// Catching exceptions is for communists// If you’re reading this, that means you have been put in charge of my previous project.
// I am so, so sorry for you. God speed.// if i ever see this again i’m going to start bringing guns to work// The magnitude of this hack compares favorably with that of the national debt.//ALL YOUR BASE ARE BELONG TO US// If this code works, it was written by Paul. If not, I don’t know who wrote it//You are not expected to understand this/** If you don’t understand this code, you should be flipping burgers instead.*/‘NO COMMENT//Abandon all hope yea who enter beyond this point//Mr. Compiler, please do not read this.catch (Ex as Exception)
{
// oh crap, we should do something.
}// TODO make this work// If you delete the credits, I will fucking kill you.// This is crap code but it’s 3 a.m. and I need to get this working.// For the sins I am about to commit, may James Gosling forgive me// Houston, we have a problem// If I from the future read this I’ll back in time and kill myself.//Code sanitized to protect the foolish.// somedev1 -  6/7/02 Adding temporary tracking of Login screen
// somedev2 -  5/22/07 Temporary my assusing System;namespace Mobile.Web.Control
{/// /// Class used to work around Richard being a fucking idiot/// /// /// The point of this is to work around his poor design so that paging will /// work on a mobile control. The main problem is the BindCompany() method, /// which he hoped would be able to do everything. I hope he dies./// public abstract class RichardIsAFuckingIdiotControl : MobileBaseControl, ICompanyProfileControl{protected abstract Pager Pager { get; }public void BindCompany(int companyId) { }public RichardIsAFuckingIdiotControl(){MakeSureNobodyAccidentallyGetsBittenByRichardsStupidity();}private void MakeSureNobodyAccidentallyGetsBittenByRichardsStupidity(){// Make sure nobody is actually using that fucking bindcompany methodMethodInfo m = this.GetType().GetMethod("BindCompany", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);if (m != null){throw new RichardIsAFuckingIdiotException("No!! Don't use the fucking BindCompany method!!!");}// P.S. this method is a joke ... the rest of the class is fucking serious}/// /// This returns true if this control is supposed to be doing anything/// at all for this request. Richard thought it was a good idea to load/// the entire website during every request and have things turn themselves/// off. He also thought bandanas and aviator sunglasses were "fuckin' /// gnarly, dude."/// protected bool IsThisTheRightPageImNotSureBecauseRichardIsDumb(){return Request.QueryString["Section"] == this.MenuItemKey;}protected override void OnLoad(EventArgs e){if (IsThisTheRightPageImNotSureBecauseRichardIsDumb()){Page.LoadComplete += new EventHandler(Page_LoadComplete);Pager.RowCount = GetRowCountBecauseRichardIsDumb();}base.OnLoad(e);}protected abstract int GetRowCountBecauseRichardIsDumb();protected abstract void BindDataBecauseRichardIsDumb();void Page_LoadComplete(object sender, EventArgs e){BindDataBecauseRichardIsDumb();}// the rest of his reduh-ndant interface memberspublic abstract string MenuItemName { get; set; }public abstract string MenuItemKey { get; set; }public abstract bool IsCapable(CapabilityCheck checker, int companyId);public abstract bool ShowInMenu { get; }public virtual Control CreateHeaderControl(){return null;}}
} 
--Collected by Tao

这篇关于代码注释之程序猿天真可爱无国界!的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/163220

相关文章

Java集合之Iterator迭代器实现代码解析

《Java集合之Iterator迭代器实现代码解析》迭代器Iterator是Java集合框架中的一个核心接口,位于java.util包下,它定义了一种标准的元素访问机制,为各种集合类型提供了一种统一的... 目录一、什么是Iterator二、Iterator的核心方法三、基本使用示例四、Iterator的工

Java 线程池+分布式实现代码

《Java线程池+分布式实现代码》在Java开发中,池通过预先创建并管理一定数量的资源,避免频繁创建和销毁资源带来的性能开销,从而提高系统效率,:本文主要介绍Java线程池+分布式实现代码,需要... 目录1. 线程池1.1 自定义线程池实现1.1.1 线程池核心1.1.2 代码示例1.2 总结流程2. J

java程序远程debug原理与配置全过程

《java程序远程debug原理与配置全过程》文章介绍了Java远程调试的JPDA体系,包含JVMTI监控JVM、JDWP传输调试命令、JDI提供调试接口,通过-Xdebug、-Xrunjdwp参数配... 目录背景组成模块间联系IBM对三个模块的详细介绍编程使用总结背景日常工作中,每个程序员都会遇到bu

JS纯前端实现浏览器语音播报、朗读功能的完整代码

《JS纯前端实现浏览器语音播报、朗读功能的完整代码》在现代互联网的发展中,语音技术正逐渐成为改变用户体验的重要一环,下面:本文主要介绍JS纯前端实现浏览器语音播报、朗读功能的相关资料,文中通过代码... 目录一、朗读单条文本:① 语音自选参数,按钮控制语音:② 效果图:二、朗读多条文本:① 语音有默认值:②

Vue实现路由守卫的示例代码

《Vue实现路由守卫的示例代码》Vue路由守卫是控制页面导航的钩子函数,主要用于鉴权、数据预加载等场景,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着... 目录一、概念二、类型三、实战一、概念路由守卫(Navigation Guards)本质上就是 在路

uni-app小程序项目中实现前端图片压缩实现方式(附详细代码)

《uni-app小程序项目中实现前端图片压缩实现方式(附详细代码)》在uni-app开发中,文件上传和图片处理是很常见的需求,但也经常会遇到各种问题,下面:本文主要介绍uni-app小程序项目中实... 目录方式一:使用<canvas>实现图片压缩(推荐,兼容性好)示例代码(小程序平台):方式二:使用uni

JAVA实现Token自动续期机制的示例代码

《JAVA实现Token自动续期机制的示例代码》本文主要介绍了JAVA实现Token自动续期机制的示例代码,通过动态调整会话生命周期平衡安全性与用户体验,解决固定有效期Token带来的风险与不便,感兴... 目录1. 固定有效期Token的内在局限性2. 自动续期机制:兼顾安全与体验的解决方案3. 总结PS

C#中通过Response.Headers设置自定义参数的代码示例

《C#中通过Response.Headers设置自定义参数的代码示例》:本文主要介绍C#中通过Response.Headers设置自定义响应头的方法,涵盖基础添加、安全校验、生产实践及调试技巧,强... 目录一、基础设置方法1. 直接添加自定义头2. 批量设置模式二、高级配置技巧1. 安全校验机制2. 类型

Python屏幕抓取和录制的详细代码示例

《Python屏幕抓取和录制的详细代码示例》随着现代计算机性能的提高和网络速度的加快,越来越多的用户需要对他们的屏幕进行录制,:本文主要介绍Python屏幕抓取和录制的相关资料,需要的朋友可以参考... 目录一、常用 python 屏幕抓取库二、pyautogui 截屏示例三、mss 高性能截图四、Pill

使用MapStruct实现Java对象映射的示例代码

《使用MapStruct实现Java对象映射的示例代码》本文主要介绍了使用MapStruct实现Java对象映射的示例代码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,... 目录一、什么是 MapStruct?二、实战演练:三步集成 MapStruct第一步:添加 Mave