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

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

      June 6, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      June 6, 2025

      How To Prevent WordPress SQL Injection Attacks

      June 6, 2025

      AI is currently in its teenage years, battling raging hormones

      June 6, 2025

      4 ways your organization can adapt and thrive in the age of AI

      June 6, 2025

      Google’s new Search tool turns financial info into interactive charts – how to try it

      June 6, 2025

      This rugged Android phone has something I’ve never seen on competing models

      June 6, 2025

      Anthropic’s new AI models for classified info are already in use by US gov

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

      Handling PostgreSQL Migrations in Node.js

      June 6, 2025
      Recent

      Handling PostgreSQL Migrations in Node.js

      June 6, 2025

      How to Add Product Badges in Optimizely Configured Commerce Spire

      June 6, 2025

      Salesforce Health Check Assessment Unlocks ROI

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

      Microsoft: Run PS script now if you deleted “inetpub” on Windows 11, Windows 10

      June 6, 2025
      Recent

      Microsoft: Run PS script now if you deleted “inetpub” on Windows 11, Windows 10

      June 6, 2025

      Spf Permerror Troubleshooting Guide For Better Email Deliverability Today

      June 6, 2025

      Amap – Gather Info in Easy Way

      June 6, 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?

    private String getDatum()
    {
        DateTime datum = new DateTime();
        datum = DateTime.Now;
        return datum.ToShortDateString();
    }
    
    public int getTag()
    {
        int tag;
        DateTime datum = new DateTime();
        datum = DateTime.Today;
        tag = datum.Day;
        return tag;
    }
    
    private int getMonat()
    {
        int monat;
        DateTime datum = new DateTime();
        datum = DateTime.Today;
        monat = datum.Month;
        return monat;
    }
    
    private int getJahr()
    {
        int monat;
        DateTime datum = new DateTime();
        datum = DateTime.Today;
        monat = datum.Year;
        return monat;
    }
    
    private int getStunde()
    {
        int monat;
        DateTime datum = new DateTime();
        datum = DateTime.Now;
        monat = datum.Hour;
        return monat;
    }
    
    private int getMinute()
    {
        int monat;
        DateTime datum = new DateTime();
        datum = DateTime.Now;
        monat = datum.Minute;
        return 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

    4 ways your organization can adapt and thrive in the age of AI

    June 6, 2025
    News & Updates

    Google’s new Search tool turns financial info into interactive charts – how to try it

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

    Anche il Team Debian abbandona X (ex Twitter): una scelta in linea con i propri valori

    Linux

    Automate Network Management Using Gen AI Ops with MongoDB

    Databases

    CVE-2025-47762 – Apple iOS Unvalidated Redirect

    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-24916 – Tenable Network Monitor Local Privilege Escalation

    Common Vulnerabilities and Exposures (CVEs)

    Highlights

    News & Updates

    Microsoft CFO urges employees to “focus” amid recent AI developments like OpenAI’s $500 billion Stargate project — but Satya Nadella says DeepSeek is good for business

    February 3, 2025

    Amy Hood urged employees to remain focused and build toward the company’s AI goals, while…

    How to Set Up Basic jQuery Form Validation in Two Minutes

    January 6, 2025

    CVE-2025-5657 – PHPGurukul Complaint Management System SQL Injection Vulnerability

    June 5, 2025

    How tech giants like Netflix built resilient systems with chaos engineering

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

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