# CodeSOD

Published articles for CodeSOD.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## CodeSOD: A Living Fossil

DevFeed: [CodeSOD: A Living Fossil](<https://devfeed.tech/articles/codesod-a-living-fossil-144729.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/a-living-fossil>)

Author: Remy Porter

Published: 2026-11-19T06:30:00Z

Content type: article

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [HTML](<https://devfeed.tech/topics/html.md>), [CSS](<https://devfeed.tech/topics/css.md>), [versioning](<https://devfeed.tech/topics/versioning.md>)

Tags: [codesod](<https://devfeed.tech/tags/codesod.md>)

### AI overview

An intranet page still receiving updates uses table-based layout, repeated line breaks, empty cells, and a sidebar border image--patterns the author describes as a surviving example of older web design. The markup suggests it may have begun in a WYSIWYG editor such as Dreamweaver, while HTML comments and later text-editor edits indicate that people also worked directly in the code. The lack of CSS points tentatively to an older site; self-closing `
` tags provide a more specific period clue. The author says the site is being replaced and jokes that it deserves a historical marker.

### Source excerpt

Today's anonymous submission is a blast from the past. This comes from an intranet HTML page that has been receiving continuous updates for some time. How long? Well, let's take a peek at how it does its layout. <b>Extension:</b> x5555
 <b>Email:</b>: <a href="mailto:blahblah@example.com"></a>

 </td> <td width=140> </td> </tr> <tr><td>&nbsp;</td></tr> <tr><td>&nbsp;</td></tr> </td> </table> </center> <!-- END DIRECTORY --> <tr><td>
</td></tr> </td> </tr> </table> <!-- MATERIAL ENDS HERE --> 
 
 </td> </tr> </table> </center> </td> </tr> <tr><td width=987 height=4 background="../images/table_bottom_sidebar.jpg"></td></tr> </table> This is like a coelecanth, or a horeshoe crab. A living fossil. There are hints that imply this started life as the output of a WYSIWYG editor, like Dreamweaver or something. The loads of line break tags, the table cells that contain only a space, and also the one table cell that contains a line break- that feels like a WYSIWYG trying to interpret what the user types. But the comments imply someone was also looking at the HTML code at some point. And certainly, in the modern era, it is being edited by someone with a text editor. The absence of CSS might point us towards a late 90s website, as by the early 00s, CSS was starting to become standard, but the thing that really pins this in a point in time is the XHTML style self-closing 
 tags. But then little quirks highlight that someone was also getting "creative" with code. The table_bottom_sidebar.jpg had related images, all designed to put borders in the table. There were matching images for left, right, and top borders. Our submitter adds: "Needless to say, this site is being replaced." Replaced? It should get a historical marker. This is how we used to do it, in the bad old days. We'd add 
&nbsp; while churning butter in homespun dresses, and we liked it. Okay, we didn't like it. But still. [Advertisement] Keep all your packages and Docker contain

## CodeSOD: Building a Line

DevFeed: [CodeSOD: Building a Line](<https://devfeed.tech/articles/codesod-building-a-line-139424.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/building-a-line>)

Author: Remy Porter

Published: 2026-11-17T06:30:00Z

Content type: article

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [concatenation](<https://devfeed.tech/topics/concatenation.md>), [IO](<https://devfeed.tech/topics/io.md>)

Tags: [abstraction](<https://devfeed.tech/tags/abstraction.md>), [builder](<https://devfeed.tech/tags/builder.md>), [codesod](<https://devfeed.tech/tags/codesod.md>), [concatenation](<https://devfeed.tech/tags/concatenation.md>), [file](<https://devfeed.tech/tags/file.md>), [function](<https://devfeed.tech/tags/function.md>), [performance](<https://devfeed.tech/tags/performance.md>), [return](<https://devfeed.tech/tags/return.md>), [string](<https://devfeed.tech/tags/string.md>)

### AI overview

The function reads a file in full, adds a line feed to the resulting string, appends that single combined value to a StringBuilder, and returns it. The author calls this a superstitious use of StringBuilder: for the current task, returning the read contents plus a line feed is simpler. Separate StringBuilder appends could make sense if the output were expected to grow or change, but the author considers that setup premature abstraction here.

### Source excerpt

There's an unofficial category of posts here that I call "Somebody told us string builders were more efficient, so we always use string builders, regardless of whether or not that actually makes sense," or STUSBWMESWAUSBROWONTAMS, for short. Probably should workshop that name some. In any case, Adam sends us a new entry for that collection: Public Function ReadFromFile(ByVal filename As String) As String Dim sb As StringBuilder = New StringBuilder() Dim str As String = String.Empty Using sr As StreamReader = File.OpenText(filename) str = sr.ReadToEnd() sb.Append(str & Constants.vbLf) End Using Return sb.ToString() End Function This function takes a filename, opens a file, reads the entire contents of the file to a variable. It concatenates a line feed to the end of the string it just read, then appends all of that to a string builder. Finally, we return sb.ToString(), taking the single string in the string builder, appending nothing to it, and returning the result. I'd almost, almost forgive the code if it was more like: str = sr.ReadToEnd() sb.Append(str) sb.Append(Constants.vbLf) You're not actually gaining much from this, but it follows the broad pattern of "use a string builder" so that if you ever wanted to change the structure of the output, you're already set up to prepend/append new text in a scalable way. I'd argue that's premature abstraction, though: a simple return sr.ReadToEnd() & Constants.vbLf would do the current job. The code that we have is a clear superstitious use of string builders. The string builder is used as a charm against poor performance, without understanding why one might use it, or how it might work; string concatenation means string builder, always and forever, "why" doesn't enter into it. [Advertisement] Keep all your packages and Docker containers in one place, scan for vulnerabilities, and control who can access different feeds. ProGet installs in minutes and has a powerful free version with a lot of great features that you can upg

## CodeSOD: Next Month

DevFeed: [CodeSOD: Next Month](<https://devfeed.tech/articles/codesod-next-month-131106.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/next-month>)

Author: Remy Porter

Published: 2026-11-12T06:30:00Z

Content type: news

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [if statement](<https://devfeed.tech/topics/if-statement.md>)

Tags: [billing](<https://devfeed.tech/tags/billing.md>), [bug](<https://devfeed.tech/tags/bug.md>), [codesod](<https://devfeed.tech/tags/codesod.md>), [net-9](<https://devfeed.tech/tags/net-9.md>)

### AI overview

A billing bug canceled all bills due in January because the code compared only the month numbers of `next_bill_date` and `end_date`, ignoring the year. When December began, January's month number was greater than or equal to the account's ending month, so the code cleared and saved those billing dates. The team could reconstruct the dates without restoring a backup, but an unknown number of customer billing periods had been canceled and required a history check.

### Source excerpt

One of Sean's colleagues left Initech on good terms. It caused no small amount of surprise that the very next day their billing system started failing. The billing system which the colleauge had worked on. No one truly suspected foul play, it was just a weird coincidence. Still, billing blowing up was a 5 alarm fire, so everyone was throwing every idea out about what could be the cause. Late in the evening, after staring at the code for many hours, Sean found this: if item.next_bill_date.month >= end_date.month item.next_bill_date = nil item.save else ... end If the month of the next billing date is greater than the last billing date for this account, wipe the billing date and update the item. It's worth noting that Sean's co-worker's last date happened to be the end of November, and billing started blowing up on the 1st of December. You'll also note this is checking just the month and not any other part of the date, like, oh, I don't know, the year? While this bug could happen to any bill, it was blowing up in December because every bill's ending month was greater than or equal to January. So this code canceled all the bills due in January. The good news was that they could reconstruct the correct next billing dates without having to restore from a backup. The bad news is that some unknown number of billing periods had been canceled for some of their customers, and someone was going to have to check the history. Sean reached out to his former co-worker to politely thank them for an early Christmas present. "At least I understand our billing code better," Sean writes. [Advertisement] Plan Your .NET 9 Migration with Confidence Your journey to .NET 9 is more than just one decision.Avoid migration migraines with the advice in this free guide. Download Free Guide Now!

## CodeSOD: Plenty of IDs

DevFeed: [CodeSOD: Plenty of IDs](<https://devfeed.tech/articles/codesod-plenty-of-ids-127496.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/plenty-of-ids>)

Author: Remy Porter

Published: 2026-11-10T06:30:00Z

Content type: article

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [Python](<https://devfeed.tech/topics/python.md>), [Code Modularity](<https://devfeed.tech/topics/code-modularity.md>), [identifier](<https://devfeed.tech/topics/identifier.md>)

Tags: [codesod](<https://devfeed.tech/tags/codesod.md>), [ids](<https://devfeed.tech/tags/ids.md>), [net](<https://devfeed.tech/tags/net.md>), [net-9](<https://devfeed.tech/tags/net-9.md>)

### AI overview

A Python VM launcher generates five-digit identifiers by sampling five distinct digits from 0-9, which limits the pool to 30,240 values rather than all 100,000 five-digit strings. The excerpt says this small pool brings a 1% collision chance after 26 requests and a 50% chance after 206, illustrating how quickly duplicate identifiers can occur despite the seemingly large number of possibilities.

### Source excerpt

Venkat joined a new team in the middle of a big refactoring effort. The code was quite a mess, glued together by long Python scripts with main functions longer than a Tolstoy novel. It was this effort to clean up the code into neat modules that highlighted some logical issues with their implementation. def generate_random_number(): """ Generate a 5 digit random number. """ return "".join(map(str, random.sample(range(0,10),5))) The script this function comes from is a launcher script that provisions a VM to execute code. The VM needs a unique identifier, and we get that random number this way. The random.sample function, in Python, samples a population without replacement. So here, we pass it a range of 0-10 (which is 0-9 inclusive), and ask for five random entries from it. Again, without replacement, so a range that could concievably contain up to 100,000 possible values is significantly constrained down to 30,000 or so- only the numbers less than 100,000 that contain no duplicate digits. We then map the resulting array into an array of strings, then join that into a final output string. Now, for most of us, I do suspect that 30,240 unique values is probably enough for how ever many VMs we might need to reserve at any one time; if you're not working for Amazon or Google or whatever, you're probably fine. Then again, the chances of an accidental collision are surprisingly high: after only 26 requests, there's a 1% chance of a collision. And thanks to the birthday problem, it takes 206 requests to get to a 50% chance of collision. So maybe 30,240 is not enough for anybody. [Advertisement] Plan Your .NET 9 Migration with Confidence Your journey to .NET 9 is more than just one decision.Avoid migration migraines with the advice in this free guide. Download Free Guide Now!

## CodeSOD: Eventually

DevFeed: [CodeSOD: Eventually](<https://devfeed.tech/articles/codesod-eventually-124205.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/eventually>)

Author: Remy Porter

Published: 2026-11-09T06:30:00Z

Content type: article

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [code comments](<https://devfeed.tech/topics/code-comments.md>), [To-Do](<https://devfeed.tech/topics/todo.md>)

Tags: [codesod](<https://devfeed.tech/tags/codesod.md>), [comment](<https://devfeed.tech/tags/comment.md>), [refactoring](<https://devfeed.tech/tags/refactoring.md>)

### AI overview

A TODO comment says a method ideally belongs in the tax framework, but was duplicated under time pressure and should later be refactored. The excerpt says the comment has remained unchanged for 23 years and the refactoring never happened.

### Source excerpt

We were just discussing TODO comments recently, and that motivated Bernard to send us this representative comment.. // TODO: This method should ideally be in tax frame work but due to // the time constraint I am duplicating the code here. // Needs to be refactored. Oct 28, 03. This comment exists in this codebase, unchanged. It has been there for twenty three years. The refactoring has never happened. This comment has seen the world change over the last 23 years, as the technology landscape has shifted and changed, grown and contracted. But this comment, this comment is a constant. [Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!

## CodeSOD: Only Create Me if I Exist

DevFeed: [CodeSOD: Only Create Me if I Exist](<https://devfeed.tech/articles/codesod-only-create-me-if-i-exist-119673.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/only-create-me-if-i-exist>)

Author: Remy Porter

Published: 2026-11-05T06:30:00Z

Content type: article

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [sql-server](<https://devfeed.tech/topics/sql-server.md>), [sql-database](<https://devfeed.tech/topics/sql-database.md>), [SQL](<https://devfeed.tech/topics/sql.md>)

Tags: [codesod](<https://devfeed.tech/tags/codesod.md>), [constraint](<https://devfeed.tech/tags/constraint.md>), [database](<https://devfeed.tech/tags/database.md>), [foreign-keys](<https://devfeed.tech/tags/foreign-keys.md>), [sql](<https://devfeed.tech/tags/sql.md>), [sql-server](<https://devfeed.tech/tags/sql-server.md>), [table](<https://devfeed.tech/tags/table.md>)

### AI overview

The excerpt shows a SQL Server constraint that makes `ListingDetails.Id` a foreign key to the same table's `Id`. Unlike a typical self-reference between different rows, each record satisfies this constraint with its own ID, so the author says it appears to work as a no-op. The author notes they have not tested it personally and bases that conclusion on cursory searching.

### Source excerpt

Foreign keys are an important part of making sure the entities in our relational database can be connected back together and queried correctly. It's part of proper data normalization. This isn't shocking, of course: the order line table has a foreign key over to the products table, so that every line item points to a product we sell. That's database 101. Database 201, you'd also think about the times where you have a hierarchy of records, where say, every Employee has a ManagerId, which is a foreign key back to the Employee table itself (and in database 301, you'll understand why having a ManagerId field is a terrible choice, but that's neither here nor there). The important thing here is that foreign keys are very common, and foreign keys pointing back to the same table are also very common. But it can still go very wrong. Roman sends us this foreign key definition in a database they maintain. ALTER TABLE [dbo].[ListingDetails] WITH CHECK ADD CONSTRAINT [FK_Listings_Listings] FOREIGN KEY([Id]) REFERENCES [dbo].[ListingDetails] ([Id]) This ensures that the ListingDetails table's Id field is a foreign key over to the ListingDetails table's Id field. A field is a foreign key back to itself. Roman writes: "I can't believe SQL Server even allows this..." I can. While I haven't personally tried this out, a bit of cursory searching implies that this does actually work- the record satisfies its own constraint, so you can still add it to the database. It's basically a no-op, which isn't great, but it's not SQL Server's job to ensure you keep all your toes because they've removed all the footguns. [Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!

## CodeSOD: Death of the Auth-Er

DevFeed: [CodeSOD: Death of the Auth-Er](<https://devfeed.tech/articles/codesod-death-of-the-auth-er-115664.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/death-of-the-auth-er>)

Author: Remy Porter

Published: 2026-11-03T06:30:00Z

Content type: article

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [conditionals](<https://devfeed.tech/topics/conditionals.md>), [Exception handling](<https://devfeed.tech/topics/exception-handling.md>), [return](<https://devfeed.tech/topics/return.md>)

Tags: [auth](<https://devfeed.tech/tags/auth.md>), [code](<https://devfeed.tech/tags/code.md>), [codesod](<https://devfeed.tech/tags/codesod.md>), [conditionals](<https://devfeed.tech/tags/conditionals.md>), [death](<https://devfeed.tech/tags/death.md>), [debugging](<https://devfeed.tech/tags/debugging.md>), [perl](<https://devfeed.tech/tags/perl.md>), [production](<https://devfeed.tech/tags/production.md>)

### AI overview

The inherited `store()` handler is effectively disabled by unconditional `die` statements: it stops at `echo 'Hello'`, before attempting authentication. Further `die`s would also halt the success and failure paths, preventing the welcome response or redirect. The author speculates these statements were added while disabling the route path by path, but says the source history is unavailable; the code reportedly remained in production for years.

### Source excerpt

When writing Perl, it's not unusual to want to die. The die function ends your Perl program with an error string, and you'll often see code like: die "My error" unless $i > 5 or die "Other error" if check(), because Perl just loves the backwards conditionals. What's even more fun with die is how it behaves with eval blocks, so it doesn't always kill your program, sometimes it is how you pass error strings back out of sections of your program. And poor Bobby has inherited some Perl that just really loves to die. public function store() { echo 'Hello'; die; if (Auth::attempt(Input::only('email', 'password'))) { echo 'done'; die; // return "welcome ".Auth::user()->username } echo "Oops! Fails"; die; return Redirect::back()->with_input(); } Bobby didn't send the source control history here, but I have a sense of what it likely was like, once. If they authenticate successfully, print a welcome message. If they don't, redirect back to the logon page and let them try again. I suspect they wanted to disable the route. So first they disabled the success path, only to discover that the failure path kept redirecting, so they disabled that too. Finally, they added the Hello at the top to disable the whole thing. Why? Why did they do any of this? No idea. It feels like debugging code, but you'd expect more echos and fewer dies if that were the case. And you wouldn't expect it to leak into production and sit there for years, which is what happened here. [Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!

## CodeSOD: Get It Now

DevFeed: [CodeSOD: Get It Now](<https://devfeed.tech/articles/codesod-get-it-now-112789.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/get-it-now>)

Author: Remy Porter

Published: 2026-11-02T06:30:00Z

Content type: article

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [code comments](<https://devfeed.tech/topics/code-comments.md>)

Tags: [codesod](<https://devfeed.tech/tags/codesod.md>), [memes](<https://devfeed.tech/tags/memes.md>)

### AI overview

The excerpt shows a TODO left unresolved in Sam C's code: a `getnow` function returns the hard-coded year `'2012'`. The commentary jokes about how unexpectedly long ago 2012 was. The excerpt provides no technical explanation or broader context for the function.

### Source excerpt

"TODO" comments are an inescapable part of our work. Yes, yes, you should just do it right the first time, everything should probably have a ticket in whatever your ticket system is for visibility, but at some point, you're just going to leave a "TODO" behind. But hopefully, the TODO gets TODONE, which is not what happened in Sam C's codebase. function getnow() { //TODO return '2012'; } It's the XKCD, but for years. Or WHAT YEAR IS IN memes. At least it's a relatively recent year, not some far off point from over a decade ago. Wait. 2012 was how long ago? That can't be right. It was just a few years ago! [Advertisement] Plan Your .NET 9 Migration with Confidence Your journey to .NET 9 is more than just one decision.Avoid migration migraines with the advice in this free guide. Download Free Guide Now!

## CodeSOD: Oh, K?

DevFeed: [CodeSOD: Oh, K?](<https://devfeed.tech/articles/codesod-oh-k-107000.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/oh-k>)

Author: Remy Porter

Published: 2026-10-29T06:30:00Z

Content type: article

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [identifier](<https://devfeed.tech/topics/identifier.md>)

Tags: [bug](<https://devfeed.tech/tags/bug.md>), [c](<https://devfeed.tech/tags/c.md>), [codesod](<https://devfeed.tech/tags/codesod.md>), [comment](<https://devfeed.tech/tags/comment.md>), [macros](<https://devfeed.tech/tags/macros.md>), [memory](<https://devfeed.tech/tags/memory.md>), [variables](<https://devfeed.tech/tags/variables.md>)

### AI overview

The inner loop uses `k` as its counter, but another statement in the same loop assigns `k = strlen(someOutputString) - 8;`, overwriting that counter. The comment misidentifies this ordinary variable reuse as a memory violation and says `l` is used to work around it. The author suspects the long, complex, macro-heavy loop made the bug hard to find; declaring the loop variable in place would improve scoping but would not fix this clobbering.

### Source excerpt

Pierre found this cry for help: for (j = 0; j < DISTRICT_CARDINALITY; j++) { /* * A poor way to work around some sort of memory * violation. k gets clobbered, so I buffer l with it. * Help? */ for (k = 0, l = 0; k < customers; k++, l++) { /* c_id */ FPRINTF(output, "%d", l + 1); METAPRINTF((output, "%c", delimiter)); Honestly, I'm always a little worried in C-like languages when the loop variable isn't scoped to the loop and declared in place. Always concerning, so when there's concerns with clobbering, I'm not surprised. This iterates across a set of "districts", and then iterates across a list of customers. Standard output functions are replaced with macros, and honestly, I don't know that I want to know what happens in METAPRINTF. But fine, this iterates across a bunch of stuff and generates output. It's the comment that we're really curious about. "Some sort of memory violation", so we duplicate our loop variable. What on earth could be happening here? Well, Pierre found the "memory violation", which is probably what you expected: k = strlen(someOutputString) - 8; k is used elsewhere in the loop as a variable. That's not a memory violation, that's just how variables work. This leaves us with one possible conclusion: the developer who wrote the comment couldn't find this bug. And given the weird use of macros here, I'm going to go out on a limb and guess that it's not the developer's fault; I strongly suspect the loop is so long, so complicated, and so obfuscated that very few developers could find that. My earlier complaint about scoping the variable to the loop wouldn't fix this, which I guess is on me. They still should really scope the variable to the loop. [Advertisement] Keep all your packages and Docker containers in one place, scan for vulnerabilities, and control who can access different feeds. ProGet installs in minutes and has a powerful free version with a lot of great features that you can upgrade when ready.Learn more.

## CodeSOD: Session Recording

DevFeed: [CodeSOD: Session Recording](<https://devfeed.tech/articles/codesod-session-recording-105625.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/session-recording>)

Author: Remy Porter

Published: 2026-10-28T06:30:00Z

Content type: article

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [ASP.NET](<https://devfeed.tech/topics/aspnet.md>), [sql-database](<https://devfeed.tech/topics/sql-database.md>), [sessions](<https://devfeed.tech/topics/sessions.md>)

Tags: [asp-net](<https://devfeed.tech/tags/asp-net.md>), [autocomplete](<https://devfeed.tech/tags/autocomplete.md>), [codesod](<https://devfeed.tech/tags/codesod.md>), [database](<https://devfeed.tech/tags/database.md>), [redirect](<https://devfeed.tech/tags/redirect.md>), [sql-injection](<https://devfeed.tech/tags/sql-injection.md>)

### AI overview

The Web Forms snippet reads an album ID from a control, stores it in session, builds and executes a SQL DELETE query using that ID and the session user ID, then redirects. The author criticizes the indirect FindControl-to-Label lookup, using a label to hold input, and the concatenated query as vulnerable to SQL injection. They also question storing the query in a page member and criticize broad use of session state, including for form inputs and loop variables. The redirect's HTTP 300 navigation and the "frm" prefix in the destination URL are additional complaints.

### Source excerpt

We still get a fair bit of old school ASP .Net webforms code, which was cutting edge about twenty years ago, but remains a collection of bad choices that tried to make web programming feel like desktop programming. As an aside, what a reversed world we live in today, where everyone uses Electron and our desktop programming feels like web programming. In any case, Thomas sends us some pretty ugly webforms code. Me.Session("Albumid") = CType(e.Item.FindControl("lblAlbumID"), Label).Text If Not Me.Session("Albumid") Is Nothing And Not Me.Session("Uid") Is Nothing Then Me.strDelSQL = "Delete from tbl_Albumshare_Mast where Album_Id=" & Me.Session("Albumid") & " and Sharer_ID=" & Me.Session("Uid") Me.objDB.ExecQry(Me.strDelSQL) Me.Response.Redirect("frmmyalbumshare.aspx", False) End If Broadly, the goal of this code is to take an album ID from the user and delete an album from the database where the ID matches and the album is owned by this user. And everything is horrible here. First, the use of e.Item.FindControl to look up the input field is suspicious. That's usually what you do when you've dynamically generated controls, but I don't think that's happening here. Because we use FindControl we have to cast it to Label, and only then can we get the text property. That itself raises a question, because why are user inputs getting stored in a label?. That's not what labels are for. They're clearly doing some sort of hacky lookup/autocomplete field thing and using the label to actually store the input, but presenting the user with a different UI for picking it. Not an uncommon pattern in those days, but a hidden field would be a more typical way of doing it. We then construct a SQL injection vulnerability and run it against the database. Then, we use a redirect to send the user to a different page. Again, a common thing to do back then, but a thing I hate: using HTTP 300 codes to redirect users as a form of navigation is awkward and weird. Of course, none of that is precise

## CodeSOD: Doing the Assignment

DevFeed: [CodeSOD: Doing the Assignment](<https://devfeed.tech/articles/codesod-doing-the-assignment-92580.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/doing-the-assignment>)

Author: Remy Porter

Published: 2026-10-21T06:30:00Z

Content type: article

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [Variable](<https://devfeed.tech/topics/variable.md>)

Tags: [codesod](<https://devfeed.tech/tags/codesod.md>)

### AI overview

The code initializes `x`, `y`, and `z` separately, then chains `x = y = z`, so `x`'s initial value of 3 is overwritten with 4. The excerpt questions why the variables are initialized this way and suggests either assigning 4 to all three in one chain or using a named constant such as `DEFAULT_VALUE` for clarity.

### Source excerpt

Today's code maybe isn't much of a WTF, but it does point in the general direction of, "Damn, you live like this?" Poor Nancy unfortunately does. int x = 3; int y = 4; int z = 4; x = y = z; Each variable is declared and initialized, and then they're set equal to each other. It just raises the question though, why do it this way? Why not declare them and then x = y = z = 4, if we want that? Or maybe, for more clarity, int x = DEFAULT_VALUE; would be more legible, and we can skip the multiple assignments on one line. Why does x get set to 3 but then overwritten? [Advertisement] ProGet's got you covered with security and access controls on your NuGet feeds. Learn more.

## CodeSOD: A Type of Type Safety

DevFeed: [CodeSOD: A Type of Type Safety](<https://devfeed.tech/articles/codesod-a-type-of-type-safety-85187.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/a-type-of-type-safety>)

Author: Remy Porter

Published: 2026-10-12T06:30:00Z

Content type: article

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [Polymorphism](<https://devfeed.tech/topics/polymorphism.md>), [Inheritance](<https://devfeed.tech/topics/inheritance.md>), [typesafety](<https://devfeed.tech/topics/typesafety.md>)

Tags: [c](<https://devfeed.tech/tags/c.md>), [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [code](<https://devfeed.tech/tags/code.md>), [codesod](<https://devfeed.tech/tags/codesod.md>), [inheritance](<https://devfeed.tech/tags/inheritance.md>), [polymorphism](<https://devfeed.tech/tags/polymorphism.md>), [type-safety](<https://devfeed.tech/tags/type-safety.md>), [type-system](<https://devfeed.tech/tags/type-system.md>)

### AI overview

The article critiques a C++ codebase that uses runtime type checks and casts to restrict behavior based on object types. It explains how this approach misuses C++ casting and contrasts it with using polymorphism and dynamic dispatch to model the domain.

### Source excerpt

For some godawful reason, people like to explain object oriented concepts via analogy to biological taxonomies. I suppose it's easy to understand an "is-a" relationship (a cat is a mammal), but the down side is you get a complex and increasingly leaky analogy that over-emphasizes the importance of inheritance. That's not to slight Alan's choice of using it to anoymize today's code. It's just a broad frustration on my part. In any case, Alan has been working in a C++ codebase that's written by people who maybe don't fully understand all the key object oriented concepts. That's why you get code like this: /* * If possible, steal tentacle from the given animal. */ void Animal::StealTentacle(Animal *animal) { // only Octopus and Squid can have tentacles if (!IS_INSTANCE_OF(this, Octopus) && !IS_INSTANCE_OF(this, Squid)) { return; } Limb *limb = animal->mLimbs->GetFirstTentacle(); if (limb) { limb->AttachToAnimal(this); // . . . This function takes a raw pointer to an Animal object. If that pointer is not an Octopus or a Squid, we bail. Otherwise, we're going to take its tentacle, and do stuff with it. Now, this is a pretty clear example of the type switch anti-pattern. Instead of using the type system and polymorphism to enforce restrictions, we instead do runtime type checks. But wait a second, what's going on in that IS_INSTANCE_OF? // I've noticed that dynamic_cast always returns a valid result when // casting an "objectPointer" of type "className". // Try casting it to a [Organism *] to force it to work. (?) #define IS_INSTANCE_OF(objectPointer, className) ((bool) (dynamic_cast<className *>(((Organism *) objectPointer)) != NULL)) #define IS_MEMBER_OF(objectPointer, className) IS_INSTANCE_OF(objectPointer, className) // temporary macro alias This code attempts to take an objectPointer and first, force it into a pointer to our base type (Organism), using a C-style cast. Now, in C++, C-style casts are a shorthand, and the compiler will, based on the context, attempt to

## CodeSOD: An Overengineered Java CLI Input Example

DevFeed: [CodeSOD: An Overengineered Java CLI Input Example](<https://devfeed.tech/articles/codesod-a-tool-for-you-66573.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/a-tool-for-you>)

Author: Remy Porter

Published: 2026-10-07T06:30:00Z

Content type: opinion

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [Test-driven development](<https://devfeed.tech/topics/tdd.md>), [Functional programming](<https://devfeed.tech/topics/functional-programming.md>)

Tags: [cli](<https://devfeed.tech/tags/cli.md>), [codesod](<https://devfeed.tech/tags/codesod.md>), [java](<https://devfeed.tech/tags/java.md>), [mentor](<https://devfeed.tech/tags/mentor.md>), [team](<https://devfeed.tech/tags/team.md>)

### AI overview

The article criticizes a senior developer's elaborate Java example for reading user input from the CLI. The code uses nested maps and map entries to handle simple responses, prompting criticism of its complexity and mentoring approach.

### Source excerpt

A junior dev on the team had a simple question: in Java, how do I correctly read user input from the CLI and act on it? Now, we can wonder about a junior dev not having such basic knowledge, but maybe they're new to Java specifically. Who knows. But Robert's team has a senior on it who "likes to mentor". This senior has strong opinions about how to write software, extreme confidence in those opinions, and has somehow been around the company long enough that he knows where the bodies are buried and no one will fire him. Here's his sample application for reading input. import java.nio.charset.StandardCharsets; import java.util.*; public class ScannerTool { public static void main(String[] args) { Map<Optional<Character>, Map.Entry<String, Boolean>> map = new HashMap<>(); map.put(Optional.of('A'), new AbstractMap.SimpleEntry<>("You entered A.", true)); map.put(Optional.of('B'), new AbstractMap.SimpleEntry<>("You entered B.", true)); map.put(Optional.empty(), new AbstractMap.SimpleEntry<>("You entered nothing.", false)); Optional<Character> input; do { System.out.println("Please enter A or B:"); } while (!map.getOrDefault((input = nextCharacter()), new AbstractMap.SimpleEntry<>("", false)) .getValue()); System.out.println(map.get(input).getKey()); } public static Optional<Character> nextCharacter() { String l = new Scanner(System.in, StandardCharsets.UTF_8).nextLine(); if (l != null && !l.isEmpty()) { return Optional.of(l.charAt(0)); } return Optional.empty(); } } Look, I know Java is verbose, but this is entirely next level. Giving this to a junior has to constitute an attempt to drive the youth out of the industry, because any sane person being told, "your job is to write this" would realize they've committed a grave error in their career choice and needs to escape now. nextCharacter in this case actually returns the first character of the next line, not the next character. And if there isn't one, it returns an empty optional. Which, fine, we only expect one character

## A Random Content Function and a Lesson About Hiring Cheaply

DevFeed: [A Random Content Function and a Lesson About Hiring Cheaply](<https://devfeed.tech/articles/codesod-a-random-article-65846.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/a-random-article>)

Author: Remy Porter

Published: 2026-10-06T06:30:00Z

Content type: opinion

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [Back end](<https://devfeed.tech/topics/backend.md>), [Data integrity in software engineering](<https://devfeed.tech/topics/data-integrity-in-software-engineering.md>)

Tags: [codesod](<https://devfeed.tech/tags/codesod.md>), [hiring](<https://devfeed.tech/tags/hiring.md>), [php](<https://devfeed.tech/tags/php.md>)

### AI overview

The article revisits an early PHP function that selects random banner content from a database by generating IDs and checking which ones exist. It calls the approach poor even by early-2000s standards, while arguing that the young developer should not bear all the blame for code produced under low-cost hiring.

### Source excerpt

Many years ago, DJ got his start doing odd web development jobs for a low hourly rate. He was only 19 when he got started, and what he lacked in experience he made up for in being cheap to hire. As I said, that was many years ago, and he has since learned a lot. But he still has some code from his very first "someone paid me for this" project. This particular function needed to pick a random bit of content from their database to display in the "right side" banner area. This is how DJ implemented it. // Create an array of all the ID's used $int = array(); $query = $sql->query("SELECT * FROM rightside"); while($row = $sql->objects('',$query)) { $int[ $row->id ] = $row->id; if ($row->id > $max) { $max = $row->id; } } // Find a random ID that has been used $x = false; while ($x == false) { $rand = rand(0,$max); foreach ($int as $thing) { if ($thing == $rand) { $x = true; } } } $query = $sql->query("SELECT * FROM rightside WHERE id = ".$rand); We start by building an array. Then we query the database for all the content. We get all the rows and columns, butw e only are interested in one- the id. We create a sparse array, where the index of the item is the item's value. We also track the max. Once we've got that, we start a loop. Inside that loop, we generate a random number, check if it's in our array by doing a foreach across the array, and if it is, we break the loop- we've found our random content. If it's not, we keep trying until we score a hit. Finally, we construct our query with string concatenation and grab the content we want to display. Now, as a true confession, there's an element of caveat emptor here; if you're hiring the kid from the local college and paying them a few bucks an hour, this is the kind of thing you get. Is the code terrible? Yes, even by early-00s PHP standards. Is it really DJ's problem, though? No. I'd hope any of us would look back at the code we wrote when we were 19, and shudder. It means we've learned something in the interim. For this

## CodeSOD: The Date and Time and Time

DevFeed: [CodeSOD: The Date and Time and Time](<https://devfeed.tech/articles/codesod-the-date-and-time-and-time-64780.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/the-date-and-time-and-time>)

Author: Remy Porter

Published: 2026-10-05T06:30:00Z

Content type: article

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [versioning](<https://devfeed.tech/topics/versioning.md>), [LocalDate](<https://devfeed.tech/topics/localdate.md>), [OffsetDateTime](<https://devfeed.tech/topics/offsetdatetime.md>), [C time functions](<https://devfeed.tech/topics/c-time-functions.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [codesod](<https://devfeed.tech/tags/codesod.md>), [java](<https://devfeed.tech/tags/java.md>), [legacy](<https://devfeed.tech/tags/legacy.md>), [software](<https://devfeed.tech/tags/software.md>), [time](<https://devfeed.tech/tags/time.md>)

### AI overview

A brief CodeSOD commentary examines legacy Java code that retrieves the current time by converting between Date and Timestamp objects. It calls the extra conversions unnecessary and describes the code as home-grown ugliness.

### Source excerpt

Today's anonymous submitter sends us some legacy Java code. The task is this: check what time it is. And fortunately, even in the older Java datetime libraries that were terrible, this was an easy task. You just needed to do something like new Date(), which constructs a date time object set to the current time. getTime() picks off just the time portion. Or, you could do this. Timestamp current = new Timestamp(new Date().getTime()); Date date = new Date(current.getTime()); This creates a date, picks the time off, populates a timestamp, gets the time from the timestamp, and constructs a new date object. The old Java date classes were awful, but they never needed you to do this. This is entirely home grown ugliness. [Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!

## CodeSOD: Very Valid Tokens

DevFeed: [CodeSOD: Very Valid Tokens](<https://devfeed.tech/articles/codesod-very-valid-tokens-63106.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/very-valid-tokens>)

Author: Remy Porter

Published: 2026-10-01T06:30:00Z

Content type: article

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [Secure token management](<https://devfeed.tech/topics/secure-token-management.md>), [Secrets Management](<https://devfeed.tech/topics/secrets-management.md>)

Tags: [authentication](<https://devfeed.tech/tags/authentication.md>), [codesod](<https://devfeed.tech/tags/codesod.md>)

### AI overview

A production authentication-token validation function unconditionally returns true, allowing any token through. The article notes that user identity is tracked separately at session start, which only marginally limits impersonation.

### Source excerpt

Today's anonymous submitter shares with us the function their company uses to validate authentication tokens. public bool IsTokenValid(string token) { //TODO return true; } This is running in production. So that's fun. The user they've authenticated as is tracked separately at the start of their session, which makes it at least marginally harder to pretend to be someone you aren't, but for authentication, any token will do. [Advertisement] Picking up NuGet is easy. Getting good at it takes time. Download our guide to learn the best practice of NuGet for the Enterprise.

## CodeSOD: Quite a Distance from the Right Solution

DevFeed: [CodeSOD: Quite a Distance from the Right Solution](<https://devfeed.tech/articles/codesod-quite-a-distance-from-the-right-solution-62828.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/quite-a-distance-from-the-right-solution>)

Author: Remy Porter

Published: 2026-09-30T06:30:00Z

Content type: article

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [Test-driven development](<https://devfeed.tech/topics/tdd.md>)

Tags: [codesod](<https://devfeed.tech/tags/codesod.md>), [math](<https://devfeed.tech/tags/math.md>), [metric](<https://devfeed.tech/tags/metric.md>), [radius](<https://devfeed.tech/tags/radius.md>)

### AI overview

The article examines a C# method that checks whether a point lies within a stated distance by iterating over integer coordinates in a square around a center. It explains that this tests a box-shaped region rather than a conventional radius and that direct bounds checks would be simpler if a box were intended.

### Source excerpt

Fritz's team needed to see if one point was within a certain distance from a center point. You or I would likely try and answer this question using a simple distance calculation, since that's the question we're trying to answer. But what if you didn't understand distances at all? Then you could write this little piece of genius. private bool IsWithin(Point point, int radius) { for (int x = -radius; x < radius + 1; x++) { for (int y = -radius; y < radius + 1; y++) { if ((PositionX == point.X + x) && (PositionY == point.Y + y)) return true; } } return false; } This limits us to integer point values, which itself is fine. This iterates across every coordinate from (x-radius,y-radius) to (x+radius,y+radius) and checks if any of them are equal to our center point, (PositionX,PositionY). Notably, this means we're not checking a radius, at least not in a traditional metric, we're checking a box (or using the taxicab metric). Which if we wanted to check a box, we actually have even easier math than the distance equation- we could do that with pure bounds checking. I've never thought to try and brute force distance checking, and that feels like a failure of my own creativity. Fritz's team mate at least was able to WTF in a way I wouldn't have considered. [Advertisement] Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.

## A Visual Basic Application's Unnecessary Padding for Historical Dates

DevFeed: [A Visual Basic Application's Unnecessary Padding for Historical Dates](<https://devfeed.tech/articles/codesod-historical-pads-59168.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/historical-pads>)

Author: Remy Porter

Published: 2026-09-24T06:30:00Z

Content type: article

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [Code](<https://devfeed.tech/topics/code.md>), [Visual Basic](<https://devfeed.tech/topics/visual-basic.md>)

Tags: [application](<https://devfeed.tech/tags/application.md>), [code](<https://devfeed.tech/tags/code.md>), [codesod](<https://devfeed.tech/tags/codesod.md>)

### AI overview

The article examines a legacy Visual Basic application's code for padding years below 1000 with a leading zero. The behavior was unnecessary because the application handled no pre-1000 dates, and later code reformatted the dates using built-in date types.

### Source excerpt

Tim inherited a fairly antique Visual Basic application some time back. Yes, Visual Basic, not VB .Net. The application is old enough that we might consider it "vintage" or "historical"; it certainly dates from before the millennium. But it has its own unique approach to handling historical dates: mnYear% = CInt(Year(vntDate)) If mnYear% < 1000 Then msYear$ = "0" & Trim$(CStr(mnYear%)) Else msYear$ = Trim$(CStr(mnYear%)) End If Insert obligatory complaints about Hungarian notation. What even is vnt. Now, one important thing about this program: it didn't have to handle dates back into the middle ages, or honestly, historical dates at all. But someone decided they wanted to make sure that if someone wanted to track the founding of the Tang Dynasty in here, you could make sure it was padded out to four digits. Unfortunately, if you wanted to track, say, the death of Caesar Augustus in 14AD, that'll only pad out to "014", which raises the question: what even is the point of this padding? And how many pre-1000 dates did the program handle? The answer to both questions is "none". Later code reformatted the date anyway, using the built in date types, even. [Advertisement] Keep all your packages and Docker containers in one place, scan for vulnerabilities, and control who can access different feeds. ProGet installs in minutes and has a powerful free version with a lot of great features that you can upgrade when ready.Learn more.

## CodeSOD: The John Cage Variable

DevFeed: [CodeSOD: The John Cage Variable](<https://devfeed.tech/articles/codesod-the-john-cage-variable-57818.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/the-john-cage-variable>)

Author: Remy Porter

Published: 2026-09-22T06:30:00Z

Content type: opinion

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [C++](<https://devfeed.tech/topics/c-plus-plus.md>), [Code](<https://devfeed.tech/topics/code.md>), [Variable](<https://devfeed.tech/topics/variable.md>), [Data structures](<https://devfeed.tech/topics/data-structures.md>)

Tags: [arrays](<https://devfeed.tech/tags/arrays.md>), [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [code](<https://devfeed.tech/tags/code.md>), [codesod](<https://devfeed.tech/tags/codesod.md>), [variable](<https://devfeed.tech/tags/variable.md>)

### AI overview

A humorous code critique examines a confusing C++ variable name and the risks of packing positional values into arrays. It argues that code written as disposable animation scripts may still be reused later, making meaningful names and maintainable structure worthwhile.

### Source excerpt

David C sends us a true confession. For my job, I write C++ code as if it was a scripting language (long story) to produce programmatic animations for videos. Given that these are "write-and-run-once-and-never-look-at-it-again" programs, I tend to not try as hard to make my code good. But once I wrote this line of code, I had to take a step back and reevaluate my life choices. fade_out(scene, length4->range(0, 3), length4_3_3, length4[4], length4[5]->range(0, 3)); This is a natural consequence of passing parameters as arrays, it seems; instead of having meaningful named values in a struct or similar, we have all these things packed into arrays. We can see a long ago attempt at using variable, badly, in the John Cage variable: length4_3_3. John Cage's (in)famous composition, "4:33" calls into question what precisely even is music, just like this variable calls into question what even is a variable name- because this is clearly a range expression of size 1. length4->range(3,1), or more reasonably, probably length4[3]. Where a normal variable name might give us some indication about what its contents mean, this gives us none of that, just a statement of how we could acquire those contents if we ever wanted them again. For disposable code, this is hardly the worst thing I've ever seen, but is any code truly disposable? You always find yourself wanting to pull some piece of it forward into the next project, inevitably. Read the third chapter of Structure and Interpretation of Computer Programs and consider yourself absolved. Go forth and sin no more. [Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!

## CodeSOD: Vintage 2013

DevFeed: [CodeSOD: Vintage 2013](<https://devfeed.tech/articles/codesod-vintage-2013-42748.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/vintage-2013>)

Author: Remy Porter

Published: 2026-09-17T06:30:00Z

Content type: article

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [Code](<https://devfeed.tech/topics/code.md>), [GNU General Public License](<https://devfeed.tech/topics/gpl.md>), [file](<https://devfeed.tech/topics/file.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [codesod](<https://devfeed.tech/tags/codesod.md>), [copyright](<https://devfeed.tech/tags/copyright.md>)

### AI overview

The article examines a malformed copyright comment in GPL-licensed Oracle code, where the year 2013 is repeated many times. It suggests the repetition may result from faulty code generation and questions the reliability of the surrounding file.

### Source excerpt

Today we have more of a representative comment, from Watson. This comes from some GPL licensed code published by everybody's favorite evil empire, Oracle. /* * Copyright (c) 2011, 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013

## CodeSOD: Extremely One Line

DevFeed: [CodeSOD: Extremely One Line](<https://devfeed.tech/articles/codesod-extremely-one-line-31464.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/extremely-one-line>)

Author: Remy Porter

Published: 2026-09-16T06:30:00Z

Content type: opinion

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [ASP.NET](<https://devfeed.tech/topics/aspnet.md>), [Code](<https://devfeed.tech/topics/code.md>), [Visual Studio](<https://devfeed.tech/topics/visual-studio.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>), [browser](<https://devfeed.tech/topics/browser.md>), [HTTP](<https://devfeed.tech/topics/http.md>)

Tags: [asp-net](<https://devfeed.tech/tags/asp-net.md>), [browser](<https://devfeed.tech/tags/browser.md>), [cli](<https://devfeed.tech/tags/cli.md>), [code](<https://devfeed.tech/tags/code.md>), [codesod](<https://devfeed.tech/tags/codesod.md>), [http](<https://devfeed.tech/tags/http.md>), [studio](<https://devfeed.tech/tags/studio.md>)

### AI overview

This CodeSOD commentary examines an ancient ASP .Net application containing a function written on one line, Safari user-agent detection, and a mysterious "uplevel" value. It criticizes the confusing style and notes that the same pattern appears on multiple pages.

### Source excerpt

Autoformatting your code is a standard thing to do these days. And in those days past, if we're being honest. There's no excuse to not use some kind of autoformatter. Whether you configure your editor to do it or are a weirdo like me who runs a formatter from the CLI as a build step, you've got an easy way to format your code so it looks neat and readable. And some IDEs, like Visual Studio, are pretty insistent about doing this for you. Which makes today's code sample a bit more perplexing. This comes from an ancient ASP .Net application that Austin has the misfortune to work with: protected void Page_PreInit(object sender, EventArgs e){if (Request.ServerVariables["http_user_agent"].IndexOf("Safari", StringComparison.CurrentCultureIgnoreCase) != -1)Page.ClientTarget = "uplevel";} protected void Page_Load(object sender, EventArgs e) { Logic(); } Which function is Logic() called from? The fact that I'm asking probably is enough to get you to scroll over. The entire Page_PreInit function is on a single line, followed by the declaration of the Page_Load function. A confusing and annoying choice. The real bonus is that if the browser has "Safari" in its user agent, we set a field to a mysterious "uplevel" value. A mix of user agent sniffing, strings as enums/flags, and wonderfully unclear names. And yes, this particular pattern appears in more than one page in Austin's application. Someone thought this was not just a good idea, but good enough to do over and over again. [Advertisement] Picking up NuGet is easy. Getting good at it takes time. Download our guide to learn the best practice of NuGet for the Enterprise.

## CodeSOD: An Odd Sort

DevFeed: [CodeSOD: An Odd Sort](<https://devfeed.tech/articles/codesod-an-odd-sort-28504.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/an-odd-sort>)

Author: Remy Porter

Published: 2026-09-15T06:30:00Z

Content type: opinion

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [Code](<https://devfeed.tech/topics/code.md>), [PowerShell](<https://devfeed.tech/topics/powershell.md>), [Script](<https://devfeed.tech/topics/script.md>), [Sorting](<https://devfeed.tech/topics/sorting.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [codesod](<https://devfeed.tech/tags/codesod.md>), [csv](<https://devfeed.tech/tags/csv.md>), [excel](<https://devfeed.tech/tags/excel.md>), [powershell](<https://devfeed.tech/tags/powershell.md>), [report](<https://devfeed.tech/tags/report.md>), [script](<https://devfeed.tech/tags/script.md>), [sorting](<https://devfeed.tech/tags/sorting.md>)

### AI overview

The article critiques a PowerShell script that queries Active Directory for users and their last logon times. It explains that the script's alphabet-based approach does not correctly sort names, performs unnecessary searches and property loading, and generates a CSV report for Excel despite these inefficiencies.

### Source excerpt

Let's say we wanted to query Active Directory and print out a report of all of our users, and their last logon time. That seems like a pretty normal task for a Powershell script. It'd probably be short and easy to read, at least if it were written by a normal person. Alice sends us one that wasn't. She's already done us a favor, as she writes: "Code cleaned up and indented for the whitespace-missing-impaired." ##################################### # lists accounts and selected attributes alphabetically ##################################### foreach( $letter in "a", "b", "c"......"z") { $strfilter = $letter + "*" $objdomain = New-object System.DirectoryServices.DirectoryEntry $objSearcher = New-object System.DirectoryServices.DirectorySearcher $objSearcher.SearchRoot = $objdomain $objSearcher.Filter = $strFilter $objSearcher.PropertiesToLoad.Add("name"); $colResults = $objSearcher.FindAll() foreach($result in $colResults) { $name = $result.Properties.Name $searcher = New-Object DirectoryServices.DirectorySearcher([adsi]"") $searcher.filter "(&(objectCategory=User)(sAMAccountName=$name))" $users = searcher.FindAll() foreach($user in $users) { Write-Output $user.properties.item("name") + "," + $user.properties.item("lastLogon") } } } This accomplishes sorting alphabetically by iterating across the alphabet. Which, I suspect, isn't going to actually get them in alphabetical order; it makes sure that albert and alice appear before bob, but doesn't enforce that albert must come before alice. In any case, we iterate across the alphabet, and then create a searcher that finds a*, then b*, etc. We explicitly tell the searcher that the only property we care about is the name field, so that we don't load unnecessary fields, like the ones we want to report on. We then iterate across the list of names, construct a new searcher, and search for the account with the username we fetched. That lets us get all of the fields we need, including the ones we aren't going to use. Now, we sea

## A File Existence Bug Caused by Checking Its Timestamp

DevFeed: [A File Existence Bug Caused by Checking Its Timestamp](<https://devfeed.tech/articles/codesod-i-exist-28510.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/i-exist>)

Author: Remy Porter

Published: 2026-09-14T06:30:00Z

Content type: article

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [bug](<https://devfeed.tech/topics/bug.md>), [software-development](<https://devfeed.tech/topics/software-development.md>), [Windows](<https://devfeed.tech/topics/windows.md>)

Tags: [bug](<https://devfeed.tech/tags/bug.md>), [code](<https://devfeed.tech/tags/code.md>), [codesod](<https://devfeed.tech/tags/codesod.md>), [development](<https://devfeed.tech/tags/development.md>), [files](<https://devfeed.tech/tags/files.md>), [function](<https://devfeed.tech/tags/function.md>), [time](<https://devfeed.tech/tags/time.md>), [windows](<https://devfeed.tech/tags/windows.md>)

### AI overview

A Pascal system library implements FileExists by checking whether FileAge returns -1. Because FileAge depends on a valid last-write timestamp, files without that timestamp are incorrectly reported as missing. The underlying failure is also not checked for its error code.

### Source excerpt

In addition to using an ancient development environment, with terrible UX, Greta also has the misfortune of working in Pascal. Recently, she was diagnosing a bug. The program was reporting that files didn't exist when they definitely existed. She traced the problem down into the system library. Let's see if you can spot what's wrong: { Delphi / Kylix Cross-Platform Runtime Library } { System Utilities Unit } { } { Copyright (c) 1995-2001 Borland Softwrare Corporation } ... function FileAge(const FileName: string): Integer; {$IFDEF MSWINDOWS} var Handle: THandle; FindData: TWin32FindData; LocalFileTime: TFileTime; begin Handle := FindFirstFile(PChar(FileName), FindData); if Handle <> INVALID_HANDLE_VALUE then begin Windows.FindClose(Handle); if (FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0 then begin FileTimeToLocalFileTime(FindData.ftLastWriteTime, LocalFileTime); if FileTimeToDosDateTime(LocalFileTime, LongRec(Result).Hi, LongRec(Result).Lo) then Exit; end; end; Result := -1; end; {$ENDIF} function FileExists(const FileName: string): Boolean; {$IFDEF MSWINDOWS} begin Result := FileAge(FileName) <> -1; end; {$ENDIF} The first function here is FileAge, which returns the last modified timestamp on a file. Note the use of FileTimeToDosDateTime, which is a Windows API function. It converts LocalFileTime and stores the date part in the first output parameter (LongRec(Result).Hi) and the time part in the second output parameter (LongRec(Result).Lo). Result, in this case, is our return value. If anything goes wrong, we return -1. The FileExists function then, simply calls FileAge. If it doesn't return a -1, there must be a file there. That's an awkward, weird solution to the problem. There has to be a system call that can answer that question more obviously. But it doesn't seem like it should be blowing up- it looks like it should work. But note that FileTimeToDosDateTime also returns a boolean value. If it succeeds, great, but if it fails, it returns false

## CodeSOD: Asynchronous Directories

DevFeed: [CodeSOD: Asynchronous Directories](<https://devfeed.tech/articles/codesod-asynchronous-directories-28505.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/asynchronous-directories>)

Author: Remy Porter

Published: 2026-09-09T06:30:00Z

Content type: article

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [Vala](<https://devfeed.tech/topics/vala.md>), [async/await](<https://devfeed.tech/topics/async-await.md>), [Library](<https://devfeed.tech/topics/library.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [async](<https://devfeed.tech/tags/async.md>), [asynchronous](<https://devfeed.tech/tags/asynchronous.md>), [await](<https://devfeed.tech/tags/await.md>), [codesod](<https://devfeed.tech/tags/codesod.md>), [exceptions](<https://devfeed.tech/tags/exceptions.md>), [filesystem](<https://devfeed.tech/tags/filesystem.md>), [writing-code](<https://devfeed.tech/tags/writing-code.md>)

### AI overview

This article examines implementing an asynchronous version of Vala's directory-creation method when the core library provides only a synchronous version. The proposed function walks up the directory tree, then creates missing directories in reverse order, using exceptions for control flow.

### Source excerpt

Eri has a mix of a "true confession" and a "wait, really?" today. The programming language Vala bills itself as a C# like language that compiles into something pretty close to C performance, designed specifically for writing code against Gnome and its associated libraries. One of the C#-isms in brings in is async/await type semantics. You can yield someAsyncFunction(), which returns control to the caller, allowing it to proceed until the yielded function returns an actual value. Because it has asynchronous functions, many library functions for handling I/O are already async. So you can make_directory_async, which yields control so you can keep executing while waiting for the filesystem to make your directory. There are also synchronous versions of those methods. And then there's create_directory_with_parents, which will create a chain of directories for you. That's the synchronous version, and Vala's core library has decided not to provide an asynchronous version of it, which is my "wait, really?" I suspect it's really about the race conditions involved and the risks of things going wrong while doing it asynchronously; all solvable problems, but tricky ones to solve. But it's the problem Eri had, and this is their solution: /// Note: does not throw if target already exists async void create_directory_with_parents_async(File file, Cancellable? cancellable = null) throws Error { var to_create = new File[0]; var? current_target = file; while(current_target != null) { try { yield current_target.make_directory_async(Priority.DEFAULT, cancellable); } catch(IOError.NOT_FOUND e) { to_create += current_target; current_target = current_target.get_parent(); continue; } catch(IOError.EXISTS e) { break; } break; } for (int i = to_create.length - 1; i >= 0; --i) { try { yield to_create[i].make_directory_async(Priority.DEFAULT, cancellable); } catch(IOError.EXISTS e) { // Created by another process } } } If I'm reading this correctly, we start by trying to create the full path to

[Next page](<https://devfeed.tech/tags/codesod.md?cursor=WyIyMDI2LTA5LTA5VDA2OjMwOjAwKzAwOjAwIiwgIjM3NjRlOGNjLTdkNGQtNGJjYy1iODZhLTY2NjVkYTI5ZTEwNyJd>)