Computer
Dell Says Data Breach Involved Customers' Physical Addresses
Read more of this story at Slashdot.
OpenAI Considers Allowing Users To Create AI-Generated Pornography
Read more of this story at Slashdot.
Microsoft's Xbox Is Planning More Cuts After Studio Closings
Read more of this story at Slashdot.
US Patent and Trademark Office Confirms Another Leak of Filers' Address Data
Read more of this story at Slashdot.
North Yorkshire Council To Ban Apostrophes On Street Signs To Avoid Database Problems
Read more of this story at Slashdot.
Scientists Find an 'Alphabet' In Whale Songs
Read more of this story at Slashdot.
CodeSOD: Reflect on Your Mistakes
While Java didn't invent putting a toString method in the base class of every object, it certainly made it mainstream. The nice thing about the method is that it allows you to turn any object into a string, though it's up to the implementor to decide what a good string representation is. But what if you want to ensure that the object you're handed is really and truly a string, not just something you can convert to a string?
teknopaul's co-worker found their own solution:
private boolean isString(Object o){ String cl = o.getClass().getName(); if (cl.equalsIgnoreCase("java.lang.String")) return true; return false; }Here, we use reflection to get the class name of an object, and if that class name is java.lang.String, then well- this must be a string!
The beauty of this method is that we lose any compile-time type-safety (which, to be fair, is a thing we risk any time we use generics). But if all the methods which want a string input just, y'know, required a string parameter, this method wouldn't be necessary.
But more than that, this breaks polymorphism. I'm not suggesting that we should go and override the string class, but if you did, that string wouldn't cause this function to return true. The isAssignableFrom function would be more appropriate than using getName, but don't confuse "more appropriate" with "actually appropriate".
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!Deepfakes of Your Dead Loved Ones Are a Booming Chinese Business
Read more of this story at Slashdot.
Dell Makes Return-To-Office Push With VPN, Badge Tracking
Read more of this story at Slashdot.
Google Will Exit Prominent San Francisco Waterfront Office Tower
Read more of this story at Slashdot.
81% of Young People Say a 4-Day Workweek Would Boost Productivity, Survey Finds
Read more of this story at Slashdot.
Ransomware Crooks Now SIM Swap Executives' Kids To Pressure Their Parents
Read more of this story at Slashdot.
US Libraries Are Battling High Prices For Better E-Book Access
Read more of this story at Slashdot.
Fedora Asahi Remix 40 Now Available For Apple Silicon Devices
Read more of this story at Slashdot.
FCC Explicitly Prohibits Fast Lanes, Closing Possible Net Neutrality Loophole
Read more of this story at Slashdot.
Smart Home Startup Brilliant Runs Out of Cash, Which Could Mean Lights Out For Its Light Switches
Read more of this story at Slashdot.
Prime Video Subs Will Soon See Ads for Amazon Products When They Hit Pause
Read more of this story at Slashdot.
Raspberry Pis Get a Built-in Remote-Access Tool: Raspberry Pi Connect
Read more of this story at Slashdot.
Environmental Changes Are Fueling Human, Animal and Plant Diseases, Study Finds
Read more of this story at Slashdot.
Researchers Warned Against Using AI To Peer Review Academic Papers
Read more of this story at Slashdot.