Feed aggregator
Apple Tells Patreon To Move Creators To In-App Purchase For Subscriptions
Read more of this story at Slashdot.
Google Says AI Agent Can Now Browse on Users' Behalf
Read more of this story at Slashdot.
US Cyber Defense Chief Uploaded Sensitive Files Into a Public Version of ChatGPT
Read more of this story at Slashdot.
Amazon is Ending Its Palm ID System for Retail, Amazon One, as It Closes Physical Stores
Read more of this story at Slashdot.
Urban Expansion in the Age of Liberalism
Read more of this story at Slashdot.
Cancer Might Protect Against Alzheimer's
Read more of this story at Slashdot.
Experian's Tech Chief Defends Credit Scores: 'We're Not Palantir'
Read more of this story at Slashdot.
There's a Rash of Scam Spam Coming From a Real Microsoft Address
Read more of this story at Slashdot.
Apple Sued by App Developer Over its Continuity Camera
Read more of this story at Slashdot.
Tim Berners-Lee Wants Us To Take Back the Internet
Read more of this story at Slashdot.
What's the 'Best' Month for New Movies and Music? A Statistical Analysis
Read more of this story at Slashdot.
430,000-Year-Old Wooden Tools Are the Oldest Ever Found
Read more of this story at Slashdot.
30,000 More UPS Jobs On the Chopping Block as Amazon Era Ends
Read more of this story at Slashdot.
Android's Full Desktop Mode Surfaces in Accidental Chromium Leak
Read more of this story at Slashdot.
'Clawdbot' Has AI Techies Buying Mac Minis
Read more of this story at Slashdot.
Amazon Cuts Another 16,000 Jobs
Read more of this story at Slashdot.
Asteroid 2024 YR4 Has a 4% Chance of Hitting the Moon
Read more of this story at Slashdot.
Ancient Martian Beach Discovered, Providing New Clues To Planet's Habitability
Read more of this story at Slashdot.
CodeSOD: A Field Terned Visible
Today's anonymous submitter sends us some C# code. This particular block of code controls whether two different columns are visible on the screen. If the field Dist_Por equals one set of constants, we display one column, if it equals a different constant, we display the other. Seems simple enough.
My question to you is this: how many nested ternaries do you need to solve this problem?
ColHectarias.Visible = Dist_Por == TIPO_DIST_COSTO.Directo ? false : Dist_Por == TIPO_DIST_COSTO.Plantilla ? false : Dist_Por == TIPO_DIST_COSTO.Hectáreas ? true : Dist_Por == TIPO_DIST_COSTO.CCosIndirecto ? true : false; ColPorcentaje.Visible = Dist_Por == TIPO_DIST_COSTO.Directo ? false : Dist_Por == TIPO_DIST_COSTO.Plantilla ? true : Dist_Por == TIPO_DIST_COSTO.Hectáreas ? false : Dist_Por == TIPO_DIST_COSTO.CCosIndirecto ? false : false;If you read through just the first ternary, you'll notice the pattern: if the field equals Directo, this is false. If the field equals Plantilla this is false. If the field equals Hectáreas, it's true. If the field equals CCosIndirecto, also true. And when you write it out that way, it's just a simple or expression: ColHectarias.Visible = Dist_Por == TIPO_DIST_COSTO.Hectáreas || Dist_Por == TIPO_DIST_COSTO.CCosIndirecto;
The ColPorcentaje column is even worse: it's only visible when Dist_Por equals TIPO_DIST_COSTO.Plantilla.
Our anonymous submitter adds:
Simple, right? If only, starting with the fact they even got the ColHectarias column name wrong: it should have been ColHectareas. Do not make the mistake of assuming those are the only lines with issues or this is the first time it happens. I known the person who wrote that and if I had any choice in the matter I would never, ever, look a their code, because my sanity drops every time I do.
[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.Amazon Inadvertently Announces Cloud Unit Layoffs In Email To Employees
Read more of this story at Slashdot.
