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

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

相关文章

springboot循环依赖问题案例代码及解决办法

《springboot循环依赖问题案例代码及解决办法》在SpringBoot中,如果两个或多个Bean之间存在循环依赖(即BeanA依赖BeanB,而BeanB又依赖BeanA),会导致Spring的... 目录1. 什么是循环依赖?2. 循环依赖的场景案例3. 解决循环依赖的常见方法方法 1:使用 @La

使用C#代码在PDF文档中添加、删除和替换图片

《使用C#代码在PDF文档中添加、删除和替换图片》在当今数字化文档处理场景中,动态操作PDF文档中的图像已成为企业级应用开发的核心需求之一,本文将介绍如何在.NET平台使用C#代码在PDF文档中添加、... 目录引言用C#添加图片到PDF文档用C#删除PDF文档中的图片用C#替换PDF文档中的图片引言在当

C#使用SQLite进行大数据量高效处理的代码示例

《C#使用SQLite进行大数据量高效处理的代码示例》在软件开发中,高效处理大数据量是一个常见且具有挑战性的任务,SQLite因其零配置、嵌入式、跨平台的特性,成为许多开发者的首选数据库,本文将深入探... 目录前言准备工作数据实体核心技术批量插入:从乌龟到猎豹的蜕变分页查询:加载百万数据异步处理:拒绝界面

用js控制视频播放进度基本示例代码

《用js控制视频播放进度基本示例代码》写前端的时候,很多的时候是需要支持要网页视频播放的功能,下面这篇文章主要给大家介绍了关于用js控制视频播放进度的相关资料,文中通过代码介绍的非常详细,需要的朋友可... 目录前言html部分:JavaScript部分:注意:总结前言在javascript中控制视频播放

Spring Boot 3.4.3 基于 Spring WebFlux 实现 SSE 功能(代码示例)

《SpringBoot3.4.3基于SpringWebFlux实现SSE功能(代码示例)》SpringBoot3.4.3结合SpringWebFlux实现SSE功能,为实时数据推送提供... 目录1. SSE 简介1.1 什么是 SSE?1.2 SSE 的优点1.3 适用场景2. Spring WebFlu

java之Objects.nonNull用法代码解读

《java之Objects.nonNull用法代码解读》:本文主要介绍java之Objects.nonNull用法代码,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐... 目录Java之Objects.nonwww.chinasem.cnNull用法代码Objects.nonN

idea中创建新类时自动添加注释的实现

《idea中创建新类时自动添加注释的实现》在每次使用idea创建一个新类时,过了一段时间发现看不懂这个类是用来干嘛的,为了解决这个问题,我们可以设置在创建一个新类时自动添加注释,帮助我们理解这个类的用... 目录前言:详细操作:步骤一:点击上方的 文件(File),点击&nbmyHIgsp;设置(Setti

SpringBoot实现MD5加盐算法的示例代码

《SpringBoot实现MD5加盐算法的示例代码》加盐算法是一种用于增强密码安全性的技术,本文主要介绍了SpringBoot实现MD5加盐算法的示例代码,文中通过示例代码介绍的非常详细,对大家的学习... 目录一、什么是加盐算法二、如何实现加盐算法2.1 加盐算法代码实现2.2 注册页面中进行密码加盐2.

python+opencv处理颜色之将目标颜色转换实例代码

《python+opencv处理颜色之将目标颜色转换实例代码》OpenCV是一个的跨平台计算机视觉库,可以运行在Linux、Windows和MacOS操作系统上,:本文主要介绍python+ope... 目录下面是代码+ 效果 + 解释转HSV: 关于颜色总是要转HSV的掩膜再标注总结 目标:将红色的部分滤

在C#中调用Python代码的两种实现方式

《在C#中调用Python代码的两种实现方式》:本文主要介绍在C#中调用Python代码的两种实现方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录C#调用python代码的方式1. 使用 Python.NET2. 使用外部进程调用 Python 脚本总结C#调