Curious Perversions in Information Technology
7k followers 6 articoli a settimana
CodeSOD: Don't Read This Email

Evan sent us 545 lines of PHP code from a file called spec_email.php. It appears to participate in sending an email, with a nice big pile of HTML in it. We're going to take it in a few chunks, because… choices were made. It opens with this check, and a few variable declarations: if(!empty($_GET['action']) && ($_GET['action'] == 'send') )...

Wed Jun 26, 2024 17:58
CodeSOD: Nothing is True

Alexander sends us this snippet, where we change our definition of truth to something which eschews concrete definitions and accepts that existence is ephemeral. Truth and false are just illusions we project onto a reality that is itself just an illusion. In the end, we are all nothing. public enum Bit { None = -1, False...

Tue Jun 25, 2024 15:02
CodeSOD: Sdrawkcab Error Handling

When interacting with RESTful web services, there's a depressingly common anti-pattern: always return status 200 OK, but embed a more meaningful status code in the body of the response. Frequently, the embedded status code is just the HTTP status code you should have returned in the first place. This "fixes" situations where you have badly behaving...

Mon Jun 24, 2024 14:53
Error'd: Just Beastly

Not to be outdone by Michael R., another prolific participant styles himself The Beast In Black. A handful of his experiences follow here. [psst. Mr Black. Check out this explanation of a half-closed interval) Buyer Beast bemoans "I knew that the global situation was bad, but when Amazon starts offering disdiscounts (or discountcounts,...

Fri Jun 21, 2024 15:21
CodeSOD: Extended Models

If I'm being completely honest, I'm mildly anti-ORM. I'm not about to go on a rampage and suggest they should absolutely, never, ever, ever be used, but I think they tend to create a lot of problems. Instead of being a true mapping between our object model and our relational model, they're their own tool, with its own idosynchracies, and a lot of "magic"...

Thu Jun 20, 2024 14:57
CodeSOD: Mostly In One Line

Today's a day for a smorgasbord. We're going to start with a classic kind of bad code, from astephens: pbUpdates.Value = int.Parse(Math.Truncate(percentage).ToString()); Here, we want to truncate a floating point down to an integer, but take a trip through a string to do it. Why? Probably because the person responsible knew about int.Parse but not...

Wed Jun 19, 2024 14:07

Costruisci il tuo feed di notizie

Pronto a fare un tentativo?
Inizia una prova di 14 giorni, nessuna carta di credito richiesta.

Crea account