17

I get angry every fucking time when I see such method signature:

method(int, int, int, string, string, string, string)

Sounds scary, doesn't it?

Nah. That's the reason our IDEs are so complex. So, I change this and put proper data value/struct class instead, just to make this much readable and understandable for everyone.

And, every time there is a fella that asks this utterly stupid question:

What about performance impact?

Aaaaaaaaaaaaaa fuckyutitititiigig

And. I. Have. To. Run. Performance. Tests.

Because noone understands performance and computers so I have to prove there is nothing to worry about.

I know when I will go somewhere else I will have to again prove some fuckwit that web applications are so complex already, so adding a new data structure doesn't impact its performance.

Comments
  • 9
    Performance impact over something like that? If that sort of thing is really an issue, then you'd be best doing the whole thing in assembly.
  • 2
    @AlmondSauce my thoughts exactly. I have been in such situation a couple of times, and it sounds so ridiculous but still you have to prove it doesn't mean anything.
  • 1
    You're right, it's easy to fall into that trap.

    The best code I write is usually the second or third fresh attempt. It lets me reconsider everything without the assumptions and limitations of the old code, I understand better where the ugly parts of the problem pop up and the uninteresting parts can often be copy-pasted from the previous iteration with minor modifications.

    Keep it simple and flexible. In many cases the compiler/runtime will completely remove a lot of abstractions anyway and can detect possible optimisations in a couple milliseconds. If you think more than a few milliseconds about the number or structure of function arguments you're probably thinking about the wrong thing.
  • 1
    What performance impact? You're allocating a class. Depending on the language now you're probably passing a reference to the object rather than copying all the primitives.

    And usability >>> performance most of the time.
  • 0
    @rolexpo all cases were in Java and if you introduce such structure there is a new object, hence additional memory has to be allocated. Nothing significant though. It's all bullshit.
  • 1
    Simple. use reflection. Everywhere. For everything.
    no more performance, no more problem.
  • 2
    @puradawid

    I see I see. What in saying is that if you make a class, it will allocate this in the heap. And now you're modifying 1 memory object instead pass by value multiple times unless you're making new objects and what not.

    Anyways, the person who brought up performance is an idiot. A method that had 7 variables definitely need a class.
  • 0
    @magicMirror hmmmmmmmmmmmmmm

    Sounds like a plan for the next battle!
  • 0
    Guilty! I used to forward declare my functions like that in C (just because I could).
  • 0
    If you have that many parameters you have a design issue not a clean code issue. Yes defining an extra pojo is a simple fix but doesn't fix underlying problems.
  • 0
    I would ask those same questions to make sure you benchmark your changes (and continue to do so on your own), not because I think it’s a performance concern. Also, performance still matters, especially in some areas. For example, in bulk processing at work, even a small change can add half an hour to the processing time.
  • 0
    Usually there is no performance impact at all unless there is some bs cost in dereferencing a value or very costly object instantiation going on. Even in PHP the object is passed as a ref (unless it's values are modified and you probably shouldn't).
Add Comment