CodeSOD: A Random Article Note

CodeSOD: A Random Article

DJ, a young and inexpensive web developer, created a function to select random content from a database. Initially, he built an array of used IDs and tracked the maximum ID value. Then, he implemented a loop to find a random ID that existed in the database. This loop would repeatedly generate random numbers until one matched an ID in the array. Once a valid random ID was found, it was used to query the database for the specific content. The author acknowledges this code is poor, even for early PHP standards. However, they argue it's understandable given DJ's age and inexperience at the time. The author believes looking back at old code and finding it cringeworthy indicates growth and learning. Therefore, they suggest DJ doesn't need to "atone" for this past work. The lesson is also directed at companies that hire inexperienced developers at very low rates.