What's the funniest comment you've encountered in code?

twitter logo github logo ・1 min read

We all put comments in code from time to time. But being a consultant means I get a chance to work with many code bases and see many funny/aggressive/upsetting comments in code. What was the most interesting comment you've seen so far?

Let's have a laugh!

twitter logo DISCUSS (11)
markdown guide
 

The worst out of context one I have seen in a codebase was :

This function kills all unadopted children

It was in relation to nested todo lists before anyone asks :).

 
 

So someone wrote a function called "rm_rf" which recursively went through and deleted all of the directories and files. The comment said something like "hmm, now why didnt I just use exec('rm -rf')" then a day later in another commit "I dunno but I probably shouldn't change it, who knows what might happen"

The other one (I know 2 for 1 special) was just "oh boy" and nothing else.

 
 

I'll have to edit this post (if I remember to), but I recently read a comment embedded in a recovered file relating to Spotify. It was something along the lines of "at some point this function wasn't needed, but we've left it in because we don't know when it was removed"

 
 

Not from my code, but when these discussions come up I always think of that one time a person wrote a code out of pure spite, with method names like

private void MakeSureNobodyAccidentallyGetsBittenByRichardsStupidity()

stackoverflow.com/a/184673

 
 

There is a classic SO thread with many, many fine examples:
stackoverflow.com/questions/184618...

and from my own hand in a recent app, at least I remembered the references:

        #region Certificate Management
        private object AssociateCertificate(Uri baseAddress, string certfile, string certpass)
        {
            // NB: The following world of pain is why we want to switch to Kestrel - getting HTTP.sys to use a specific cert is awful.
            // Load the cert..
            // Always ensure the private key is exportable & correctly persisted, thanks Windows:
            // https://stackoverflow.com/questions/13076915/ssl-certificate-add-failed-when-binding-to-port
            // https://stackoverflow.com/questions/4198493/x509certificate2-has-private-key-not-exportable
            // https://stackoverflow.com/questions/10498580/private-keys-get-deleted-unexpectedly-in-windows-server-2008-r2
            X509Certificate2 x509 = new X509Certificate2(certfile, certpass, X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.MachineKeySet);
            // Ensure it's persisted in the right store (LocalMachine\My)
            // NB: We cannot do this without being an administrative account, but then we can't listen for HTTP either, thanks Windows:
            X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
            store.Open(OpenFlags.ReadWrite);
            if (!store.Certificates.Contains(x509))
            {

                Trace.WriteLine("Adding cert to store");
                store.Add(x509);
            }
            store.Close();
            // re-bind it to the listen port - always remove then add, thanks Windows: https://github.com/PKISharp/win-acme/issues/371
            ICertificateBindingConfiguration config = new CertificateBindingConfiguration();
            Guid appId = System.Runtime.InteropServices.Marshal.GetTypeLibGuidForAssembly(System.Reflection.Assembly.GetExecutingAssembly());
            IPEndPoint ep = new IPEndPoint(0, baseAddress.Port);
            try { if (config.Query(ep) != null) config.Delete(ep); } catch { }
            config.Bind(new CertificateBinding(x509.Thumbprint, StoreName.My, ep, appId));
            return baseAddress;
        }
 
Classic DEV Post from Feb 5

If/else or just if?

It's a simple question that cuts deep.

Yaser Adel Mehraban  profile image
An almond croissant addict cleverly disguised as a web developer