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

      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

      Here’s why network infrastructure is vital to maximizing your company’s AI adoption

      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

      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
      Recent

      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

      Microsoft wraps up the week with new Windows 11 preview builds, one each for Dev & Beta

      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

    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
    News & Updates

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

    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

    Windows 0-Day Vulnerability Exploited in the Wild to Deploy Play Ransomware

    Security

    You can produce video ads in seconds with Amazon’s new AI tool – here’s how

    News & Updates
    How to Build a Multilingual Social Recipe Application with Flutter and Strapi

    How to Build a Multilingual Social Recipe Application with Flutter and Strapi

    Development

    CVE-2025-4084 – “Firefox/Thunderbird Escaping Vulnerability (Local Code Execution)”

    Common Vulnerabilities and Exposures (CVEs)

    Highlights

    From SplitText to MorphSVG: 5 Creative Demos Using Free GSAP Plugins

    May 19, 2025

    GSAP’s premium plugins are now free, and this article explores their creative potential through five…

    CVE-2025-34025 – Versa Concerto Privilege Escalation and Container Escape Vulnerability

    May 22, 2025

    Russia-Linked APT28 Exploited MDaemon Zero-Day to Hack Government Webmail Servers

    May 15, 2025

    Top Generative AI Companies in the World

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

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