Skip to content
DevMeme
2851 of 7590
CodeQuality Post #3149 · source on Telegram

When your Unity method’s parameter list becomes a CVS receipt

Description

The meme is styled like a dark-theme tweet. In blue text it tags “@unity3d” followed by the question: “How many inputs you want to pass through the method?” On the next line, the reply simply says “Me: Yes.” Beneath the tweet is a code screenshot showing a C# method signature highlighted in a code editor: “void MemoryPuzzleDataManager.SavingSessionData(int playRoundCount, int condition, int trial, int complexity, bool status, bool isShapeCorrect, List<int> boardSelection, List<int> userSelection, List<char> userSelectionHand, int numberOfTimesRightHandUsedInTrial, int numberOfTimesLeftHandUsedInTrial, int numberOfTimeRightHandUsedInTotal, int numberOfTimeLeftHandUsedInTotal, double FirstSelectionTime, double trialCompletionTime, double averageFirstSelectionTime, double averageTrialCompletionTime)”. The absurdly long list of parameters satirizes poor API design, highlighting code smell issues like long parameter lists and maintainability headaches common in Unity C# projects, eliciting relatable developer humor about clean-code violations

Comments

20
Anonymous ★ Top Pick Pro tip: when your Unity SaveSession method has so many parameters it’s flirting with the Ethernet MTU, you’re no longer passing arguments - you’re reinventing JSON with worse ergonomics
  1. Anonymous ★ Top Pick

    Pro tip: when your Unity SaveSession method has so many parameters it’s flirting with the Ethernet MTU, you’re no longer passing arguments - you’re reinventing JSON with worse ergonomics

  2. Anonymous

    This is what happens when you treat method signatures like a NoSQL document - eventually someone will ask 'but can we also pass the kitchen sink?' and the answer will still be another parameter at position 47

  3. Anonymous

    When Unity asks how many parameters you need and you answer 'yes,' you end up with a method signature so long it needs its own scroll bar. This is the architectural equivalent of ordering everything on the menu because you couldn't decide - except instead of indigestion, you get a maintenance nightmare that makes every code reviewer weep. At this point, the method isn't just violating the Single Responsibility Principle; it's running a full-scale insurgency against it. Pro tip: if your method signature requires a parameter object, a builder pattern, and possibly a therapist, it's time to refactor

  4. Anonymous

    Unity: “How many inputs?” Me: “Yes.” At 18 parameters the call site is basically positional JSON, and every bug is a permutation we could’ve avoided with a Parameter Object and a domain model

  5. Anonymous

    This is the LongParameterList × PrimitiveObsession speedrun - just take a SessionTelemetry DTO and pass an ID; your stack trace deserves to fit on one monitor

  6. Anonymous

    Unity mantra: Why define a SaveData struct when one method can shoulder the parameter apocalypse?

  7. @s2504s 5y

    A telescopic constructor

  8. @s2504s 5y

    But it's life )

  9. Deleted Account 5y

    if you have more than 3 parameters, then you are doing something wrong.

    1. @RiedleroD 5y

      aye, just using the main config class to do this (& changing data along the way instead of collecting it once dumping happens) would be more efficient.

      1. Deleted Account 5y

        yeah exactly, that’s the right way to do imho. the function should be something like MemoryPuzzleDataManager.savesession(SessionData data). i know that code is joke but i’ve seen people coding like that so it just brings terrorizing memories about fixing bugs in those codes

        1. @RiedleroD 5y

          aye

    2. @FunnyGuyU 5y

      Yup, that is why we will make 20 overloads.

    3. Deleted Account 5y

      make it a struct

    4. @karim_mahyari 5y

      Exactly, thank you

  10. Deleted Account 5y

    * except for some edge cases

  11. @aso1datov 5y

    Can you pass object with this fields? Like in javascript: function({ param1, param2, param3}) {}

  12. @borkick 5y

    *Encapsulation left this chat*

  13. @tarasssssssssssssss 5y

    that's why unity sucks btw

    1. @Almamu 5y

      More like op's method sucks, that screams for a class or a struct at that point

Use J and K for navigation