Computer
German Firms' 4-Day Workweek Trial Slashes Stress, Keeps Productivity High
Read more of this story at Slashdot.
'A New Gaming CPU King': AMD's New Ryzen 7 9800X3D Reviewed
Read more of this story at Slashdot.
Facebook Asks US Supreme Court To Dismiss Fraud Suit Over Cambridge Analytica Scandal
Read more of this story at Slashdot.
UK Will Legislate Against AI Risks in Next Year, Pledges Kyle
Read more of this story at Slashdot.
Detroit Is Turning Lampposts Into Internet-Connected EV Chargers
Read more of this story at Slashdot.
Corning's Gorilla Glass Under EU Antitrust Investigation
Read more of this story at Slashdot.
AI Workers Seek Whistleblower Cover To Expose Emerging Threats
Read more of this story at Slashdot.
Google Has No Duty To Refund Gift Card Scam Victims, Judge Finds
Read more of this story at Slashdot.
AI's Huge Power Needs Give Oil Majors Incentive To Invest in Renewables, Says Adnoc Boss
Read more of this story at Slashdot.
China Reveals a New Heavy Lift Rocket That Is a Clone of SpaceX's Starship
Read more of this story at Slashdot.
Trump Wins US Presidency For Second Time
Read more of this story at Slashdot.
CodeSOD: Uniquely Validated
There's the potential for endless installments of "programmers not understanding how UUIDs work." Frankly, I think the fact that we represent them as human readable strings is part of the problem; sure, it's readable, but conceals the fact that it's just a large integer.
Which brings us to this snippet, from Capybara James.
if (!StringUtils.hasLength(uuid) || uuid.length() != 36) { throw new RequestParameterNotFoundException(ErrorCodeCostants.UUID_MANDATORY_OR_FORMAT); }StringUtils.hasLength comes from the Spring library, and it's a simple "is not null or empty" check. So- we're testing to see if a string is null or empty, or isn't exactly 36 characters long. That tells us the input is bad, so we throw a RequestParameterNotFoundException, along with an error code.
So, as already pointed out, a UUID is just a large integer that we render as a 36 character string, and there are better ways to validate a UUID. But this also will accept any 36 character string- as long as you've got 36 characters, we'll call it a UUID. "This is valid, really valid, dumbass" is now a valid UUID.
With that in mind, I also like the bonus of it not distinguishing between whether or not the input was missing or invalid, because that'll make it real easy for users to understand why their input is getting rejected.
[Advertisement] ProGet’s got you covered with security and access controls on your NuGet feeds. Learn more.Google CEO Forbids Political Talk After Firing 28 Over Israeli Contract Protest
Read more of this story at Slashdot.
Bitcoin Hits All-Time High
Read more of this story at Slashdot.
Korean Cinema in 'Precarious Period' Due To Netflix, Says Director Jang Joon-hwan
Read more of this story at Slashdot.
Google Asked To Remove 10 Billion 'Pirate' Search Results
Read more of this story at Slashdot.
Schneider Electric Ransomware Crew Demands $125k Paid in Baguettes
Read more of this story at Slashdot.
Amazon CEO Denies Full In-Office Mandate is 'Backdoor Layoff'
Read more of this story at Slashdot.
The Hyperloop Lives On As a 1/12th Scale Model In Switzerland
Read more of this story at Slashdot.
Interpol Disrupts Cybercrime Activity On 22,000 IP Addresses, Arrests 41
Read more of this story at Slashdot.