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

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

相关文章

C#实现千万数据秒级导入的代码

《C#实现千万数据秒级导入的代码》在实际开发中excel导入很常见,现代社会中很容易遇到大数据处理业务,所以本文我就给大家分享一下千万数据秒级导入怎么实现,文中有详细的代码示例供大家参考,需要的朋友可... 目录前言一、数据存储二、处理逻辑优化前代码处理逻辑优化后的代码总结前言在实际开发中excel导入很

SpringBoot+RustFS 实现文件切片极速上传的实例代码

《SpringBoot+RustFS实现文件切片极速上传的实例代码》本文介绍利用SpringBoot和RustFS构建高性能文件切片上传系统,实现大文件秒传、断点续传和分片上传等功能,具有一定的参考... 目录一、为什么选择 RustFS + SpringBoot?二、环境准备与部署2.1 安装 RustF

Python实现Excel批量样式修改器(附完整代码)

《Python实现Excel批量样式修改器(附完整代码)》这篇文章主要为大家详细介绍了如何使用Python实现一个Excel批量样式修改器,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一... 目录前言功能特性核心功能界面特性系统要求安装说明使用指南基本操作流程高级功能技术实现核心技术栈关键函

python获取指定名字的程序的文件路径的两种方法

《python获取指定名字的程序的文件路径的两种方法》本文主要介绍了python获取指定名字的程序的文件路径的两种方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要... 最近在做项目,需要用到给定一个程序名字就可以自动获取到这个程序在Windows系统下的绝对路径,以下

Redis实现高效内存管理的示例代码

《Redis实现高效内存管理的示例代码》Redis内存管理是其核心功能之一,为了高效地利用内存,Redis采用了多种技术和策略,如优化的数据结构、内存分配策略、内存回收、数据压缩等,下面就来详细的介绍... 目录1. 内存分配策略jemalloc 的使用2. 数据压缩和编码ziplist示例代码3. 优化的

Python 基于http.server模块实现简单http服务的代码举例

《Python基于http.server模块实现简单http服务的代码举例》Pythonhttp.server模块通过继承BaseHTTPRequestHandler处理HTTP请求,使用Threa... 目录测试环境代码实现相关介绍模块简介类及相关函数简介参考链接测试环境win11专业版python

Python从Word文档中提取图片并生成PPT的操作代码

《Python从Word文档中提取图片并生成PPT的操作代码》在日常办公场景中,我们经常需要从Word文档中提取图片,并将这些图片整理到PowerPoint幻灯片中,手动完成这一任务既耗时又容易出错,... 目录引言背景与需求解决方案概述代码解析代码核心逻辑说明总结引言在日常办公场景中,我们经常需要从 W

使用Spring Cache本地缓存示例代码

《使用SpringCache本地缓存示例代码》缓存是提高应用程序性能的重要手段,通过将频繁访问的数据存储在内存中,可以减少数据库访问次数,从而加速数据读取,:本文主要介绍使用SpringCac... 目录一、Spring Cache简介核心特点:二、基础配置1. 添加依赖2. 启用缓存3. 缓存配置方案方案

MySQL的配置文件详解及实例代码

《MySQL的配置文件详解及实例代码》MySQL的配置文件是服务器运行的重要组成部分,用于设置服务器操作的各种参数,下面:本文主要介绍MySQL配置文件的相关资料,文中通过代码介绍的非常详细,需要... 目录前言一、配置文件结构1.[mysqld]2.[client]3.[mysql]4.[mysqldum

Python多线程实现大文件快速下载的代码实现

《Python多线程实现大文件快速下载的代码实现》在互联网时代,文件下载是日常操作之一,尤其是大文件,然而,网络条件不稳定或带宽有限时,下载速度会变得很慢,本文将介绍如何使用Python实现多线程下载... 目录引言一、多线程下载原理二、python实现多线程下载代码说明:三、实战案例四、注意事项五、总结引