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

      From Data To Decisions: UX Strategies For Real-Time Dashboards

      September 13, 2025

      Honeycomb launches AI observability suite for developers

      September 13, 2025

      Low-Code vs No-Code Platforms for Node.js: What CTOs Must Know Before Investing

      September 12, 2025

      ServiceNow unveils Zurich AI platform

      September 12, 2025

      Building personal apps with open source and AI

      September 12, 2025

      What Can We Actually Do With corner-shape?

      September 12, 2025

      Craft, Clarity, and Care: The Story and Work of Mengchu Yao

      September 12, 2025

      Distribution Release: Q4OS 6.1

      September 12, 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

      Optimizely Mission Control – Part III

      September 14, 2025
      Recent

      Optimizely Mission Control – Part III

      September 14, 2025

      Learning from PHP Log to File Example

      September 13, 2025

      Online EMI Calculator using PHP – Calculate Loan EMI, Interest, and Amortization Schedule

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

      sudo vs sudo-rs: What You Need to Know About the Rust Takeover of Classic Sudo Command

      September 14, 2025
      Recent

      sudo vs sudo-rs: What You Need to Know About the Rust Takeover of Classic Sudo Command

      September 14, 2025

      Dmitry — The Deep Magic

      September 13, 2025

      Right way to record and share our Terminal sessions

      September 13, 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.

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> LoggingRule <span class="hljs-title">FindFirst</span> (<span class="hljs-params"><span class="hljs-keyword">this</span> IEnumerable<LoggingRule> rules, Func<LoggingRule, <span class="hljs-built_in">bool</span>> predicate</span>)</span>
    {
            <span class="hljs-keyword">foreach</span> (LoggingRule rule <span class="hljs-keyword">in</span> rules) {
                    <span class="hljs-keyword">return</span> rule;
            }
            <span class="hljs-keyword">return</span> <span class="hljs-literal">null</span>;
    }
    

    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

    Building personal apps with open source and AI

    September 12, 2025
    News & Updates

    What Can We Actually Do With corner-shape?

    September 12, 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

    CVE-2025-41438 – “CS5000 Fire Panel Default Account Privilege Escalation”

    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-42966 – SAP NetWeaver Java Deserialization Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    New AI Framework Evaluates Where AI Should Automate vs. Augment Jobs, Says Stanford Study

    Machine Learning

    How to Use the View Transition API for Better Web Transitions

    Development

    Highlights

    Development

    U.S. Agencies Warn of Rising Iranian Cyberattacks on Defense, OT Networks, and Critical Infrastructure

    June 30, 2025

    U.S. cybersecurity and intelligence agencies have issued a joint advisory warning of potential cyber-attacks from…

    CVE-2025-6145 – TOTOLINK EX1200T HTTP POST Request Handler Buffer Overflow Vulnerability

    June 16, 2025

    mpvpaper – video wallpaper software

    May 17, 2025

    CVE-2025-8808 – Tianti CSV Injection Vulnerability

    August 10, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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