Computer
Even Harvard MBAs Are Struggling To Land Jobs
Read more of this story at Slashdot.
Google is Making AI in Gmail and Docs Free - But Raising the Price of Workspace
Read more of this story at Slashdot.
Microsoft Relaunches Copilot for Business With Free AI Chat and Pay-As-You-Go Agents
Read more of this story at Slashdot.
Meta Says It Isn't Ending Fact-Checks Outside US 'At This Time'
Read more of this story at Slashdot.
TikTok Users Flocks To Chinese Social App Xiaohongshu
Read more of this story at Slashdot.
Parallels Can Now Run x86 Windows and Linux On Apple Silicon Mac
Read more of this story at Slashdot.
CodeSOD: Brushing Up
Keige inherited some code which seems to be part of a drawing application. It can load brush textures from image files- at least, sometimes it can.
static public Brush GetImageBrush(string serviceCode, string imageName, string language) { Brush BorderChannelGroupBrush; BitmapImage image = null; int point = imageName.LastIndexOf('.'); string languageImagename = imageName.Substring(0, point) + "-" + language + imageName.Substring(point); try { image = FrameWork.ServicePageImageUrlOnContentServer(serviceCode, languageImagename); } catch { } if (image == null) { try { image = FrameWork.ServicePageImageUrlOnContentServer(serviceCode, imageName); } catch { } } if (image != null) { BorderChannelGroupBrush = new ImageBrush(image); } else { BorderChannelGroupBrush = Brushes.White; } return BorderChannelGroupBrush; }There are a lot of interesting "choices" made in this code. First, there's the old "find the last '.'" approach of grabbing the file extension. Which is fine, but there's a built-in which handles cases like when there isn't an extension better. I think, in this case, it probably doesn't hurt anything.
But the real fun starts with our first attempt at loading our image. We jam a localized language string in the middle of the file name (foo-en.jpg), and try and fetch that from the server. If this fails, it throws an exception… which we ignore.
But we don't fully ignore it! If the exception was thrown, image doesn't get set, so it's still null. So we do a null check, and repeat our empty exception handler. If the image is still null after that, we default to a "Brushes.White" image.
It's all a very awkward and weird way to handle errors. The null checks bring with them the whiff of a C programmer checking return codes, but I don't actually think that's what happened here. I think this was just someone not fully understanding the problem they were trying to solve or the tools available to them. Or maybe they just really didn't want to deal with nesting.
It's hardly the worst code, but it does just leave me feeling weird when I look at 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 upgrade when ready.Learn more.US Deaths Expected To Outpace Births Within the Decade
Read more of this story at Slashdot.
Australian Open Avatars Helping Tennis Reach New Audience
Read more of this story at Slashdot.
Pixelfed, Instagram's Decentralized Competitor, Is Now On iOS and Android
Read more of this story at Slashdot.
OpenAI's AI Reasoning Model 'Thinks' In Chinese Sometimes, No One Really Knows Why
Read more of this story at Slashdot.
US Finalizes Rule To Effectively Ban Chinese Vehicles
Read more of this story at Slashdot.
Microsoft Pauses Hiring In US Consulting Unit
Read more of this story at Slashdot.
ChatGPT Now Lets You Schedule Reminders and Recurring Tasks
Read more of this story at Slashdot.
Texas Sues Allstate For Collecting Driver Data To Raise Premiums
Read more of this story at Slashdot.
How Research Credibility Suffers in a Quantified Society
Read more of this story at Slashdot.
US Removes Malware Allegedly Planted on Computers By Chinese-Backed Hackers
Read more of this story at Slashdot.
Double-keyed Browser Caching Is Hitting Web Performance
Read more of this story at Slashdot.
Nearly Three-Quarters of All Known Bacterial Species Have Never Been Studied
Read more of this story at Slashdot.
Nobel Prize Winners Call For Urgent 'Moonshot' Effort To Avert Global Hunger Catastrophe
Read more of this story at Slashdot.