Feed aggregator
Xiaomi EV Involved in First Fatal Autopilot Crash
Read more of this story at Slashdot.
Alan Turing Institute Plans Revamp in Face of Criticism and Technological Change
Read more of this story at Slashdot.
CodeSOD: A Ruby Encrusted Footgun
Many years ago, JP joined a Ruby project. This was in the heyday of Ruby, when every startup on Earth was using it, and if you weren't building your app on Rails, were you even building an app?
Now, Ruby offers a lot of flexibility. One might argue that it offers too much flexibility, especially insofar as it permits "monkey patching": you can always add new methods to an existing class, if you want. Regardless of the technical details, JP and the team saw that massive flexibility and said, "Yes, we should use that. All of it!"
As these stories usually go, that was fine- for awhile. Then one day, a test started failing because a class name wasn't defined. That was already odd, but what was even odder is that when they searched through the code, that class name wasn't actually used anywhere. So yes, there was definitely no class with that name, but also, there was no line of code that was trying to instantiate that class. So where was the problem?
def controller_class(name) "#{settings.app_name.camelize}::Controllers".constantize.const_get("#{name.to_s.camelize}") end def model_class(name) "#{settings.app_name.camelize}".constantize.const_get("#{name.to_s.camelize}") end def resource_class(name) "#{settings.app_name.camelize}Client".constantize.const_get("#{name.to_s.camelize}") endIt happened because they were dynamically constructing the class names from a settings field. And not just in this handful of lines- this pattern occurred all over the codebase. There were other places where it referenced a different settings field, and they just hadn't encountered the bug yet, but knew that it was only a matter of time before changing a settings file was going to break more functionality in the application.
They wisely rewrote these sections to not reference the settings, and dubbed the pattern the "Caramelize Pattern". They added that to their coding standards as a thing to avoid, and learned a valuable lesson about how languages provide footguns.
Since today's April Fool's Day, consider the prank the fact that everyone learned their lesson and corrected their mistakes. I suppose that has to happen at least sometimes.
[Advertisement] Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.Anthropic Will Begin Sweeping Offices For Hidden Devices
Read more of this story at Slashdot.
First Flight of Isar Aerospace's Spectrum Rocket Lasted Just 40 Seconds
Read more of this story at Slashdot.
'There is No Vibe Engineering'
Read more of this story at Slashdot.
Intel CEO Lip-Bu Tan Says Company Will Spin Off Non-Core Units
Read more of this story at Slashdot.
UK's GCHQ Intern Transferred Top Secret Files To His Phone
Read more of this story at Slashdot.
Intel and Microsoft Staff Allegedly Lured To Work For Fake Chinese Company In Taiwan
Read more of this story at Slashdot.
OpenAI Plans To Release a New 'Open' AI Language Model In the Coming Months
Read more of this story at Slashdot.
Google To Pay $100 Million To Settle 14-Year-Old Advertising Lawsuit
Read more of this story at Slashdot.
Honey Lost 4 Million Chrome Users After Shady Tactics Were Revealed
Read more of this story at Slashdot.
ChatGPT 'Added One Million Users In the Last Hour'
Read more of this story at Slashdot.
Open Source Genetic Database Shuts Down To Protect Users From 'Authoritarian Governments'
Read more of this story at Slashdot.
Netflix CEO Says Movie Theaters Are Dead
Read more of this story at Slashdot.
Micron Hikes Memory Prices Amid Surging AI Demand
Read more of this story at Slashdot.
Microsoft Shutters AI Lab in Shanghai, Signalling a Broader Pullback From China
Read more of this story at Slashdot.
'No Longer Think You Should Learn To Code,' Says CEO of AI Coding Startup
Read more of this story at Slashdot.
Publishers Trial Paying Peer Reviewers - What Did They Find?
Read more of this story at Slashdot.
Apple Fined $162 Million for App Privacy System That Harms Developers
Read more of this story at Slashdot.