Computer
Amazon's Ring To Stop Letting Police Request Doorbell Video From Users
Read more of this story at Slashdot.
Thousands of Artists Allege Midjourney Used Their Work To Train AI Software
Read more of this story at Slashdot.
Delta Air Lines Boeing 757 Lost Nose Wheel Before Takeoff, FAA Says
Read more of this story at Slashdot.
Apple Plans New Fees and Restrictions for Downloads Outside App Store
Read more of this story at Slashdot.
New Blood Test That Screens For Alzheimer's May Be a Step Closer To Reality, Study Suggests
Read more of this story at Slashdot.
Netflix Says That Game Engagement Tripled in 2023
Read more of this story at Slashdot.
CodeSOD: Replacing a City
Mateus inherited some code where half the variables were named things like strAux1 and strAux2. It was a data driven application, and the data had some conventions that weren't always ideal; for example, every city also had an associated abbreviation stored in its name field, e.g., "SAO PAULO (SP)" and "RIO DE JANEIRO (RJ)".
The original developers wanted to be able to present the names of cities without the abbreviation, so they wrote this:
RTRIM(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( REPLACE(REPLACE(UPPER(ISNULL(C.CITY,'')),'(RS)',''), '(SC)',''),'(PR)',''),'(SP)',''),'(MG)',''),'(RJ)',''), '(DF)',''),'(ES)',''),'(MS)',''),'(MT)',''),'(BA)',''), '(PI)',''),'(AL)',''),'(TO)',''),'(PE)',''),'(PA)',''), '(CE)',''),'(RN)',''),'(MA)',''),'(AP)',''),'(RR)',''), '(RN)',''),'(AM)',''),'(AC)',''),'(XX)',''),'(EX)',''), '(SE)',''),'(PB)',''),'(GO)',''),'(RO)',''))Whitespace added for readability(?).
The good news is that I don't think Brazil is going to be adding any major cities deserving of their own abbreviation any time soon. But by effectively hard-coding the list of viable abbreviations instead of using more advanced string splitting (or *gasp* a regex), or y'know actually normalizing the data correctly, they've done a nice job making the code harder to maintain.
REPLACE REPLACE REPLACE REPLACE this code.
[Advertisement] ProGet’s got you covered with security and access controls on your NuGet feeds. Learn more.Alaska Air CEO Says Loose Bolts Found in 'Many' Boeing Jets
Read more of this story at Slashdot.
Ebay To Eliminate 1,000 Jobs, or 9% of Full-Time Workforce
Read more of this story at Slashdot.
Apple Dials Back Car's Self-Driving Features and Delays Launch To 2028
Read more of this story at Slashdot.
Netflix is Going To Take Away Its Cheapest Ad-Free Plan
Read more of this story at Slashdot.
Biden Aims To Stop Countries From Exploiting Americans' Data for Blackmail, Espionage
Read more of this story at Slashdot.
FTC Bans TurboTax From Advertising 'Free' Services, Calls It Deceptive
Read more of this story at Slashdot.
Gummy Vitamins Are Just Candy
Read more of this story at Slashdot.
Google Chrome Gains AI Features Including a Writing Helper
Read more of this story at Slashdot.
China Quietly Pulls Draft Gaming Rules From Website
Read more of this story at Slashdot.
We Need To Talk About Franklin Templeton
Read more of this story at Slashdot.
Palworld Embroiled in AI and Pokemon 'Plagiarism' Controversy
Read more of this story at Slashdot.
Netflix Buys Rights To WWE's 'Raw,' Its First Big Live Event
Read more of this story at Slashdot.
EFF Adds Street Surveillance Hub So Americans Can Check Who's Checking On Them
Read more of this story at Slashdot.