61

Dear coworker: oh my god we aren't in highschool algebra; using "x" as the name of a parameter makes me want to cut you.

Comments
  • 1
    I actually name variables like that to test the output of methods on debug. Then I remove them or rename them.
  • 8
    Sure, we all write x and foo and bar when fiddling with stuff. But he uses x in real code that gets checked in >.<
  • 2
    @Christine im assuming it's not a coordinate?
  • 1
    I wish!
  • 3
    @PaddiM8 I'm all about using single character variables in linq statements, but they still should not be x.

    customers.Select(c => c.LastName);

    customers.ToLookup(k => k.Zipcode, v=> v)

    k and v for keys and values when needed. Otherwise, a relevant character.

    The coworker in question, of course, almost always uses x. Except for today, when I saw the letter c used for no apparent reason πŸ™ƒ
  • 1
    @Christine Untill you program in R and c is a global and quite critical function.

    Ran into this too many times, assign something to a, b, c, d, e, etc to test and wonder for hours why nothing works πŸ˜‚
  • 4
    Did you ask him Y
  • 1
    Uh, I use x and y frequently for variables used in grid matrix operations, like SetPixel(x, y, color);
  • 0
    It's very common in FP code to use names like x, y, a, b (primitives), xs, ys (collections), T, U (for a type), f, g (functions) and so on.
  • 2
    @JohanO And that makes sense. It's a graph. The situations I'm complaining about has nothing to do with coordinates.
  • 1
    I always name my variables, e.g. alice, bob, casper, makes everything more personal.
  • 2
    @monnef In generic functions in FP it often makes sense, because:

    1. The convention is that types are a, b, c; functions f, g, h; values are x, y, z and lists are xs, ys, zs — and you see this convention so often that anything else would be confusing.

    2. The functions usually operate on such abstract concepts that other names make little sense anyway.

    3. The abstractions are more easily derived from the type signature than from the value names.

    Take map for example:

    map :: (a -> b) -> [a] -> [b]
    map _ [] = []
    map f (x:xs) = f x : map f xs

    Both a and b can (separately from each other) be strings, connection handlers, json objects or colors. All that matters is defined in the type signature: You pass a function which takes 'a' and gives 'b', you pass a list of 'a', and get a list of 'b'.
  • 1
    // list of customers from the database
    global List<Customer> x = gcl();

    // TODO documentation
    List<Customer> gcl() { ... }

    α–—βΈŸ Κ–Μ―βΈŸα–˜
  • 1
    It's difficult to name stuff when you don't even know what you are doing πŸ˜‰
  • 2
    I once tried to understand code which involved matrix multiplication.
    Instead of using the available Matrix class or at least arrays the author wrote 16 single ints per matrix, naming them m00, m01, m03 and did all calculations by writing everything down (without a single loop). He didn't even name the matrices according to their purpose, but all with random single letters.

    I was feeling so much hate that day...
Add Comment