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

      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

      Integrating CSS Cascade Layers To An Existing Project

      September 11, 2025

      How React.js AI Code Generation Accelerates Digital Transformation Initiatives

      September 11, 2025

      GitHub Availability Report: August 2025

      September 11, 2025

      GitHub Copilot coding agent 101: Getting started with agentic workflows on GitHub

      September 11, 2025

      Compiling Multiple CSS Files into One

      September 11, 2025

      When Cells Collide: The Making of an Organic Particle Experiment with Rapier & Three.js

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

      PHP 8.5.0 Beta 3 available for testing

      September 12, 2025
      Recent

      PHP 8.5.0 Beta 3 available for testing

      September 12, 2025

      Stock Prediction using Python machine Learning (ML)

      September 12, 2025

      How to Successfully Upgrade Angular 16 to 17: Handling Legacy Angular Material Components

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

      Pironman 5 Max Review: Best Raspberry Pi Case Money can Buy

      September 12, 2025
      Recent

      Pironman 5 Max Review: Best Raspberry Pi Case Money can Buy

      September 12, 2025

      Distribution Release: Voyager Live 13

      September 11, 2025

      FOSS Weekly #25.37: Mint 22.2 Released, Official KDE Distro, Kazeta Linux for 90s Gaming, Ubuntu 25.10’s New Terminal and More Linux Stuff

      September 11, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CodeSOD: The Getter Setter Getter

    CodeSOD: The Getter Setter Getter

    September 11, 2025

    Today’s Java snippet comes from Capybara James.

    The first sign something was wrong was this:

    <span class="hljs-keyword">private</span> Map<String, String> <span class="hljs-title function_">getExtractedDataMap</span><span class="hljs-params">(PayloadDto payload)</span> {
        <span class="hljs-keyword">return</span> setExtractedDataToMap(payload);
    }
    

    Java conventions tell us that a get method retrieves a value, and a set method mutates the value. So a getter that calls a setter is… confusing. But neither of these are truly getters nor setters.

    setExtractedDataToMap converts the PayloadDto to a Map<String, String>. getExtractedMap just calls that, which is just one extra layer of indirection that nobody needed, but whatever. At its core, this is just two badly named methods where there should be one.

    But that distracts from the true WTF in here. Why on Earth are we converting an actual Java object to a Map<String,String>? That is a definite code smell, a sign that someone isn’t entirely comfortable with object-oriented programming. You can’t even say, “Well, maybe for serialization to JSON or something?” because Java has serializers that just do this transparently. And that’s just the purpose of a DTO in the first place- to be a bucket that holds data for easy serialization.

    We’re left wondering what the point of all of this code is, and we’re not alone. James writes:

    I found this gem of a code snippet while trying to understand a workflow for data flow documentation purpose. I was not quite sure what the original developer was trying to achieve and at this point I just gave up

    [Advertisement] Picking up NuGet is easy. Getting good at it takes time. Download our guide to learn the best practice of NuGet for the Enterprise.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleHow to Design Accessible Browser Extensions
    Next Article Vendor Access Policy

    Related Posts

    News & Updates

    GitHub Availability Report: August 2025

    September 11, 2025
    News & Updates

    GitHub Copilot coding agent 101: Getting started with agentic workflows on GitHub

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

    12 Best Free and Open Source Text-Based Bookmark Managers

    Linux

    Red Hat announces Advanced Developer Suite

    Tech & Work

    CVE-2025-48125 – WP Event Manager PHP Remote File Inclusion Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Ubuntu 25.10 Fixes the Dock’s Inconsistent Radii

    Linux

    Highlights

    Machine Learning

    Google AI Releases MLE-STAR: A State-of-the-Art Machine Learning Engineering Agent Capable of Automating Various AI Tasks

    August 3, 2025

    MLE-STAR (Machine Learning Engineering via Search and Targeted Refinement) is a state-of-the-art agent system developed…

    What’s the Real Cost of Building an AI Solution in 2025? A Comprehensive Guide💰

    May 15, 2025

    Simplify access control and auditing for Amazon SageMaker Studio using trusted identity propagation

    August 19, 2025

    A UN Human Rights Council report lists Microsoft among big tech companies that “profit” from Gaza genocide

    July 6, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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