Curious Perversions in Information Technology
7k followers 5 artículos/semana
CodeSOD: Reflect on Your Mistakes

While Java didn't invent putting a toString method in the base class of every object, it certainly made it mainstream. The nice thing about the method is that it allows you to turn any object into a string, though it's up to the implementor to decide what a good string representation is. But what if you want to ensure that the object you're handed is...

Thu May 9, 2024 15:24
Coded Smorgasbord: Minimal Commentary

Comments explain a lot about our code. And sometimes, the comments explain more than the code itself. Alastair found this lovely comment, which demonstrates an excellent, if confusing, understanding of a boolean "or": // Only add delivery option if it has no weight bands or at least one weight band. The developer has left the company, so no one...

Wed May 8, 2024 15:21
CodeSOD: Suspicious Contents

While poring through some VB .Net code, John noticed some odd things in their datamodel. For example, a different process would scan files, and log any "suspicious" files into a database. The program John supported would then report on that data. One of their classes had a property which looked like this: Public ReadOnly Property SuspectedItem As...

Tue May 7, 2024 14:32
CodeSOD: Spaced Out Replacement

You have some text, and need to replace every sequence of spaces with a single space. E.g., My text becomes My text. Now, if you're most of us, you ignore the famous quote and reach straight for regexes. But Samuel's co-worker isn't most of us. toReturn = toReturn.Replace(" ", " "); toReturn = toReturn.Replace(" ", " ").Replace(" ", " ").Replace("...

Mon May 6, 2024 14:31
Error'd: Testing 1,2,3,4,5

An anonymous friend sent us our frist test in prod for this week. And then there will be more, and more, and more. "This came up in Kaspersky's Blog's RSS. If you're lucky they might still have the error up in the original URL." I don't know if "chron" is just how "cron" translates to Russian and back, but the test appears to have succeeded....

Fri May 3, 2024 14:37
CodeSOD: Totally Valid

Greg's co-worker really wanted to make sure that a variable was correctly set to true or false. So they did this: if (isValid == true) { isValid = true; } else { isValid = false; } If isValid is true, set it to true, otherwise set it to false. isValid is a boolean in C#, so the only options it could have are true and false. The real WTF...

Thu May 2, 2024 14:07

Crea tu propio feed de noticias

¿Listo para probarlo?
Comienza una prueba de 14 días, no es necesaria tarjeta de crédito.

Crear cuenta