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

      This week in AI updates: Mistral’s new Le Chat features, ChatGPT updates, and more (September 5, 2025)

      September 6, 2025

      Designing For TV: Principles, Patterns And Practical Guidance (Part 2)

      September 5, 2025

      Neo4j introduces new graph architecture that allows operational and analytics workloads to be run together

      September 5, 2025

      Beyond the benchmarks: Understanding the coding personalities of different LLMs

      September 5, 2025

      Hitachi Energy Pledges $1B to Strengthen US Grid, Build Largest Transformer Plant in Virginia

      September 5, 2025

      How to debug a web app with Playwright MCP and GitHub Copilot

      September 5, 2025

      Between Strategy and Story: Thierry Chopain’s Creative Path

      September 5, 2025

      What You Need to Know About CSS Color Interpolation

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

      Why browsers throttle JavaScript timers (and what to do about it)

      September 6, 2025
      Recent

      Why browsers throttle JavaScript timers (and what to do about it)

      September 6, 2025

      How to create Google Gemini AI component in Total.js Flow

      September 6, 2025

      Drupal 11’s AI Features: What They Actually Mean for Your Team

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

      Harnessing GitOps on Linux for Seamless, Git-First Infrastructure Management

      September 6, 2025
      Recent

      Harnessing GitOps on Linux for Seamless, Git-First Infrastructure Management

      September 6, 2025

      How DevOps Teams Are Redefining Reliability with NixOS and OSTree-Powered Linux

      September 5, 2025

      Distribution Release: Linux Mint 22.2

      September 4, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CodeSOD: Dating in Another Language

    CodeSOD: Dating in Another Language

    April 23, 2025

    It takes a lot of time and effort to build a code base that exceeds 100kloc. Rome wasn’t built in a day; it just burned down in one.

    Liza was working in a Python shop. They had a mildly successful product that ran on Linux. The sales team wanted better sales software to help them out, and instead of buying something off the shelf, they hired a C# developer to make something entirely custom.

    Within a few months, that developer had produced a codebase of 320kloc I say “produced” and not “wrote” because who knows how much of it was copy/pasted, stolen from Stack Overflow, or otherwise not the developer’s own work.

    You have to wonder, how do you get such a large codebase so quickly?

    <span class="hljs-function"><span class="hljs-keyword">private</span> String <span class="hljs-title">getDatum</span>()</span>
    {
        DateTime datum = <span class="hljs-keyword">new</span> DateTime();
        datum = DateTime.Now;
        <span class="hljs-keyword">return</span> datum.ToShortDateString();
    }
    
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-built_in">int</span> <span class="hljs-title">getTag</span>()</span>
    {
        <span class="hljs-built_in">int</span> tag;
        DateTime datum = <span class="hljs-keyword">new</span> DateTime();
        datum = DateTime.Today;
        tag = datum.Day;
        <span class="hljs-keyword">return</span> tag;
    }
    
    <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-built_in">int</span> <span class="hljs-title">getMonat</span>()</span>
    {
        <span class="hljs-built_in">int</span> monat;
        DateTime datum = <span class="hljs-keyword">new</span> DateTime();
        datum = DateTime.Today;
        monat = datum.Month;
        <span class="hljs-keyword">return</span> monat;
    }
    
    <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-built_in">int</span> <span class="hljs-title">getJahr</span>()</span>
    {
        <span class="hljs-built_in">int</span> monat;
        DateTime datum = <span class="hljs-keyword">new</span> DateTime();
        datum = DateTime.Today;
        monat = datum.Year;
        <span class="hljs-keyword">return</span> monat;
    }
    
    <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-built_in">int</span> <span class="hljs-title">getStunde</span>()</span>
    {
        <span class="hljs-built_in">int</span> monat;
        DateTime datum = <span class="hljs-keyword">new</span> DateTime();
        datum = DateTime.Now;
        monat = datum.Hour;
        <span class="hljs-keyword">return</span> monat;
    }
    
    <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-built_in">int</span> <span class="hljs-title">getMinute</span>()</span>
    {
        <span class="hljs-built_in">int</span> monat;
        DateTime datum = <span class="hljs-keyword">new</span> DateTime();
        datum = DateTime.Now;
        monat = datum.Minute;
        <span class="hljs-keyword">return</span> monat;
    }
    

    Instead of our traditional “bad date handling code” which eschews the built-in libraries, this just wraps the built in libraries with a less useful set of wrappers. Each of these could be replaced with some version of DateTime.Now.Minute.

    You’ll notice that most of the methods are private, but one is public. That seems strange, doesn’t it? Well this set of methods was pulled from one random class which implements them in the codebase, but many classes have these methods copy/pasted in. At some point, the developer realized that duplicating that much code was a bad idea, and started marking them as public, so that you could just call them as needed. Note, said developer never learned to use the keyword static, so you end up calling the method on whatever random instance of whatever random class you happen to have handy. The idea of putting it into a common base class, or dedicated date-time utility class never occurred to the developer, but I guess that’s because they were already part of a dedicated date-time utility class.

    [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 ArticleNethSecurity is a Linux firewall based on OpenWrt, a distribution
    Next Article CVE-2025-1056 – Axis Camera Station Pro File Path Traversal Vulnerability

    Related Posts

    News & Updates

    Hitachi Energy Pledges $1B to Strengthen US Grid, Build Largest Transformer Plant in Virginia

    September 5, 2025
    News & Updates

    How to debug a web app with Playwright MCP and GitHub Copilot

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

    Rolex Datejust Super Clone Watches – Top Quality Replica for Sale – Thesuperclonewatches

    Web Development

    CVE-2025-32407 – Samsung Internet for Galaxy Watch TLS Certificate Validation Bypass

    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-4604 – Liferay Portal/Captcha Bypass Remote Code Execution

    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-7547 – Campcodes Online Movie Theater Seat Reservation System Unrestricted File Upload Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Highlights

    Your Android phone just got a major Gemini upgrade for free – Samsung models included

    April 7, 2025

    More people can now have a conversation with Gemini about what’s on their screen, including…

    Over 1,500 PostgreSQL Servers Compromised in Fileless Cryptocurrency Mining Campaign

    April 1, 2025

    Next.js vs. Traditional React: What Businesses Need to Know

    June 4, 2025

    ONLYOFFICE Docs 9.0 is here: discover the redesigned interface, diagram viewer, AI tools and more

    June 18, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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