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

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

相关文章

golang程序打包成脚本部署到Linux系统方式

《golang程序打包成脚本部署到Linux系统方式》Golang程序通过本地编译(设置GOOS为linux生成无后缀二进制文件),上传至Linux服务器后赋权执行,使用nohup命令实现后台运行,完... 目录本地编译golang程序上传Golang二进制文件到linux服务器总结本地编译Golang程序

使用Docker构建Python Flask程序的详细教程

《使用Docker构建PythonFlask程序的详细教程》在当今的软件开发领域,容器化技术正变得越来越流行,而Docker无疑是其中的佼佼者,本文我们就来聊聊如何使用Docker构建一个简单的Py... 目录引言一、准备工作二、创建 Flask 应用程序三、创建 dockerfile四、构建 Docker

Python中注释使用方法举例详解

《Python中注释使用方法举例详解》在Python编程语言中注释是必不可少的一部分,它有助于提高代码的可读性和维护性,:本文主要介绍Python中注释使用方法的相关资料,需要的朋友可以参考下... 目录一、前言二、什么是注释?示例:三、单行注释语法:以 China编程# 开头,后面的内容为注释内容示例:示例:四

Java中调用数据库存储过程的示例代码

《Java中调用数据库存储过程的示例代码》本文介绍Java通过JDBC调用数据库存储过程的方法,涵盖参数类型、执行步骤及数据库差异,需注意异常处理与资源管理,以优化性能并实现复杂业务逻辑,感兴趣的朋友... 目录一、存储过程概述二、Java调用存储过程的基本javascript步骤三、Java调用存储过程示

Visual Studio 2022 编译C++20代码的图文步骤

《VisualStudio2022编译C++20代码的图文步骤》在VisualStudio中启用C++20import功能,需设置语言标准为ISOC++20,开启扫描源查找模块依赖及实验性标... 默认创建Visual Studio桌面控制台项目代码包含C++20的import方法。右键项目的属性:

MySQL数据库的内嵌函数和联合查询实例代码

《MySQL数据库的内嵌函数和联合查询实例代码》联合查询是一种将多个查询结果组合在一起的方法,通常使用UNION、UNIONALL、INTERSECT和EXCEPT关键字,下面:本文主要介绍MyS... 目录一.数据库的内嵌函数1.1聚合函数COUNT([DISTINCT] expr)SUM([DISTIN

Java实现自定义table宽高的示例代码

《Java实现自定义table宽高的示例代码》在桌面应用、管理系统乃至报表工具中,表格(JTable)作为最常用的数据展示组件,不仅承载对数据的增删改查,还需要配合布局与视觉需求,而JavaSwing... 目录一、项目背景详细介绍二、项目需求详细介绍三、相关技术详细介绍四、实现思路详细介绍五、完整实现代码

Go语言代码格式化的技巧分享

《Go语言代码格式化的技巧分享》在Go语言的开发过程中,代码格式化是一个看似细微却至关重要的环节,良好的代码格式化不仅能提升代码的可读性,还能促进团队协作,减少因代码风格差异引发的问题,Go在代码格式... 目录一、Go 语言代码格式化的重要性二、Go 语言代码格式化工具:gofmt 与 go fmt(一)

HTML5实现的移动端购物车自动结算功能示例代码

《HTML5实现的移动端购物车自动结算功能示例代码》本文介绍HTML5实现移动端购物车自动结算,通过WebStorage、事件监听、DOM操作等技术,确保实时更新与数据同步,优化性能及无障碍性,提升用... 目录1. 移动端购物车自动结算概述2. 数据存储与状态保存机制2.1 浏览器端的数据存储方式2.1.

基于 HTML5 Canvas 实现图片旋转与下载功能(完整代码展示)

《基于HTML5Canvas实现图片旋转与下载功能(完整代码展示)》本文将深入剖析一段基于HTML5Canvas的代码,该代码实现了图片的旋转(90度和180度)以及旋转后图片的下载... 目录一、引言二、html 结构分析三、css 样式分析四、JavaScript 功能实现一、引言在 Web 开发中,