Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      June 3, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      June 3, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      June 3, 2025

      How To Prevent WordPress SQL Injection Attacks

      June 3, 2025

      All the WWE 2K25 locker codes that are currently active

      June 3, 2025

      PSA: You don’t need to spend $400+ to upgrade your Xbox Series X|S storage

      June 3, 2025

      UK civil servants saved 24 minutes per day using Microsoft Copilot, saving two weeks each per year according to a new report

      June 3, 2025

      These solid-state fans will revolutionize cooling in our PCs and laptops

      June 3, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Community News: Latest PECL Releases (06.03.2025)

      June 3, 2025
      Recent

      Community News: Latest PECL Releases (06.03.2025)

      June 3, 2025

      A Comprehensive Guide to Azure Firewall

      June 3, 2025

      Test Job Failures Precisely with Laravel’s assertFailedWith Method

      June 3, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      All the WWE 2K25 locker codes that are currently active

      June 3, 2025
      Recent

      All the WWE 2K25 locker codes that are currently active

      June 3, 2025

      PSA: You don’t need to spend $400+ to upgrade your Xbox Series X|S storage

      June 3, 2025

      UK civil servants saved 24 minutes per day using Microsoft Copilot, saving two weeks each per year according to a new report

      June 3, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»CodeSOD: A Little Extra Padding

    CodeSOD: A Little Extra Padding

    January 5, 2025

    Today’s anonymous submitter supplies us with a classic antipattern: padding via switch:

    string TransactionOrder = (string)dr["TransactionOrder"].ToString().Trim();
    
    switch (TransactionOrder.Length)
    {
            case 1:
                    TransactionOrder = "000" + TransactionOrder;
                    break;
            case 2:
                    TransactionOrder = "00" + TransactionOrder;
                    break;
            case 3:
                    TransactionOrder = "0" + TransactionOrder;
                    break;
            default:
                    TransactionOrder = TransactionOrder;
                    break;
    }
    

    There’s not much to say here, as we’ve seen this before, and we’ll see it again. It’s wrong, it’s not how anything should be done, yet here it is, yet again. In this case, it’s C#, which also has a lovely set of built-in options for doing this, making this code totally unnecessary.

    [Advertisement]
    ProGet’s got you covered with security and access controls on your NuGet feeds. Learn more.

    Source: Read More 

    news
    Facebook Twitter Reddit Email Copy Link
    Previous ArticleHow to Create Partitions in Linux Using fdisk Command
    Next Article Microsoft Bing is trying to spoof Google UI when people search Google.com

    Related Posts

    Development

    The Front-End Monitoring Handbook: Track Performance, Errors, and User Behavior

    June 3, 2025
    Artificial Intelligence

    Markus Buehler receives 2025 Washington Award

    June 3, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    Casper Network Pauses Operations After Cyberattack: What You Need to Know

    Development

    A better way to control shape-shifting soft robots

    Artificial Intelligence

    CVE-2025-48847 – Dropbox Unvalidated Redirect

    Common Vulnerabilities and Exposures (CVEs)

    AWS Secrets Manager – A Secure Solution for Protecting Your Data

    Development

    Highlights

    infinitypaul/laravel-password-history-validation

    November 28, 2024

    Prevent users from reusing recently used passwords Source: Read More 

    CVE-2025-40623 – TCMAN GIM SQL Injection

    May 6, 2025

    Google is officially replacing Assistant with Gemini – and there’s only one way to keep it

    March 17, 2025

    Vulnerabilità di sicurezza in Linux: come i rootkit basati su io_uring aggirano i sistemi di rilevamento

    May 4, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.