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

      How To Prevent WordPress SQL Injection Attacks

      June 15, 2025

      This week in AI dev tools: Apple’s Foundations Model framework, Mistral’s first reasoning model, and more (June 13, 2025)

      June 13, 2025

      Open Talent platforms emerging to match skilled workers to needs, study finds

      June 13, 2025

      Java never goes out of style: Celebrating 30 years of the language

      June 12, 2025

      DistroWatch Weekly, Issue 1126

      June 15, 2025

      It’s the year of Linux… at least for Denmark — here’s why the country’s government is dumping Windows and Office 365

      June 15, 2025

      Grounded 2’s best feature is happening because Obsidian left the Xbox One behind

      June 15, 2025

      6 registry tweaks every tech-savvy user must apply on Windows 11

      June 14, 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

      Right Invoicing App for iPhone: InvoiceTemple

      June 14, 2025
      Recent

      Right Invoicing App for iPhone: InvoiceTemple

      June 14, 2025

      Tunnel Run game in 170 lines of pure JS

      June 14, 2025

      Integrating Drupal with Salesforce SSO via SAML and Dynamic User Sync

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

      Microsoft has a new tool to get you off Windows 10 and onto a Windows 11 PC

      June 15, 2025
      Recent

      Microsoft has a new tool to get you off Windows 10 and onto a Windows 11 PC

      June 15, 2025

      DistroWatch Weekly, Issue 1126

      June 15, 2025

      Find ASCII Emoji Easily with this GNOME Shell Applet

      June 15, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CodeSOD: Find the First Function to Cut

    CodeSOD: Find the First Function to Cut

    April 30, 2025

    Sebastian is now maintaining a huge framework which, in his words, “could easily be reduced in size by 50%”, especially because many of the methods in it are reinvented wheels that are already provided by .NET and specifically LINQ.

    For example, if you want the first item in a collection, LINQ lets you call First() or FirstOrDefault() on any collection. The latter option makes handling empty collections easier. But someone decided to reinvent that wheel, and like so many reinvented wheels, it’s worse.

    public static LoggingRule FindFirst (this IEnumerable<LoggingRule> rules, Func<LoggingRule, bool> predicate)
    {
            foreach (LoggingRule rule in rules) {
                    return rule;
            }
            return null;
    }
    

    This function takes a list of logging rules and a function to filter the logging rules, starts a for loop to iterate over the list, and then simply returns the first element in the list, thus exiting the for loop. If the loop doesn’t contain any elements, we return null.

    From the signature, I’d expect this function to do filtering, but it clearly doesn’t. It just returns the first element, period. And again, there’s already a built-in function for that. I don’t know why this is exists, but I especially dislike that it’s so misleading.

    There’s only one positive to say about this: if you did want to reduce the size of the framework by 50%, it’s easy to see where I’d start.

    [Advertisement]
    BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleHalwan Linux is an Arch-based distro for developers
    Next Article 6 Best Free and Open Source Econometric Software

    Related Posts

    News & Updates

    DistroWatch Weekly, Issue 1126

    June 15, 2025
    News & Updates

    It’s the year of Linux… at least for Denmark — here’s why the country’s government is dumping Windows and Office 365

    June 15, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    Kasasa snips and pins useful information

    Linux

    Should Children Use AI Chatbots? Google Thinks So, Critics Strongly Disagree

    Development

    This tiny SSD can have up to 8TB of storage, and I could fit a dozen of them in my pockets

    News & Updates

    Epic crossover: Age of Empires joins forces with the world’s most popular museum for a historic exhibit

    News & Updates

    Highlights

    Ago is a small static blog generator without any fuzz

    June 9, 2025

    Ago is a small static blog generator without any fuzz. It’s stupidly simple, not at…

    CVE-2024-10635 – Enterprise Protection S/MIME Attachment Defense Improper Input Validation

    April 28, 2025

    Google CEO says AGI is impossible with today’s tech, but Sam Altman claims “you’ll be happy to have a new device”

    June 10, 2025

    CVE-2025-24349 – CtrlX OS Network Interfaces HTTP Request Deletion Vulnerability

    April 30, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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