Computer
Samsung and Google Partner To Launch Ballie Home Robot with Built-in Projector
Read more of this story at Slashdot.
China Raises Tariffs on US Goods To 84% as Rift Escalates
Read more of this story at Slashdot.
Enterprises Are Shunning Vendors in Favor of DIY Approach To AI, UBS Says
Read more of this story at Slashdot.
CodeSOD: Single or Mingle
Singletons is arguably the easiest to understand design pattern, and thus, one of the most frequently implemented design patterns, even- especially- when it isn't necessary. Its simplicity is its weakness.
Bartłomiej inherited some code which implemented this pattern many, many times. None of them worked quite correctly, and all of them tried to create a singleton a different way.
For example, this one:
public class SystemMemorySettings { private static SystemMemorySettings _instance; public SystemMemorySettings() { if (_instance == null) { _instance = this; } } public static SystemMemorySettings GetInstance() { return _instance; } public void DoSomething() { ... // (this must only be done for singleton instance - not for working copy) if (this != _instance) { return; } ... } }The only thing they got correct was the static method which returns an instance, but everything else is wrong. They construct the instance in the constructor, meaning this isn't actually a singleton, since you can construct it multiple times. Each new construction replaces the shared instance with a new one.
The real "magic" here, however, is the DoSomething, which checks if the currently active instance is also the most recently constructed instance. If it isn't, this function just fails silently and does nothing.
A common critique of singletons is that they're simply "global variables with extra steps," but this doesn't even succeed at that- it's just a failure, top to bottom.
[Advertisement] Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.Clean Energy Powered 40% of Global Electricity in 2024, Report Finds
Read more of this story at Slashdot.
Fake Job Seekers Are Flooding US Companies
Read more of this story at Slashdot.
Hackers Spied on 100 US Bank Regulators' Emails for Over a Year
Read more of this story at Slashdot.
UK Creating 'Murder Prediction' Tool To Identify People Most Likely To Kill
Read more of this story at Slashdot.
Microsoft Cancels $1 Billion Ohio Data Center Projects
Read more of this story at Slashdot.
Razer Pauses Direct Laptop Sales in the US as New Tariffs Loom
Read more of this story at Slashdot.
Middle-Aged Man Trading Cards Go Viral in Rural Japan Town
Read more of this story at Slashdot.
China's Biotech Advances Threaten US Dominance, Warns Congressional Report
Read more of this story at Slashdot.
Shopify CEO Says Staffers Need To Prove Jobs Can't Be Done By AI Before Asking for More Headcount
Read more of this story at Slashdot.
Micron To Impose Tariff-Related Surcharge on SSDs, Other Products
Read more of this story at Slashdot.
Meta Got Caught Gaming AI Benchmarks
Read more of this story at Slashdot.
India's 'Frankenstein' Laptop Economy Thrives Against Planned Obsolescence
Read more of this story at Slashdot.
Bluesky Can't Take a Joke
Read more of this story at Slashdot.
CodeSOD: Insanitize Your Inputs
Honestly, I don't know what to say about this code sent to us by Austin, beyond "I think somebody was very confused".
string text; text = ""; // snip box.Text = text; text = ""; text = XMLUtil.SanitizeXmlString(text);This feels like it goes beyond the usual cruft and confusion that comes with code evolving without ever really being thought about, and ends up in some space outside of meaning. It's all empty strings, signifying nothing, but we've sanitized it.
[Advertisement] Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.US's AI Lead Over China Rapidly Shrinking, Stanford Report Says
Read more of this story at Slashdot.
No, the Dire Wolf Has Not Been Brought Back From Extinction
Read more of this story at Slashdot.