Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I actually name variables like that to test the output of methods on debug. Then I remove them or rename them.
-
Sure, we all write x and foo and bar when fiddling with stuff. But he uses x in real code that gets checked in >.<
-
@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 π -
Froot75407y@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 π -
JohanO20487yUh, I use x and y frequently for variables used in grid matrix operations, like SetPixel(x, y, color);
-
monnef3137yIt'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.
-
@JohanO And that makes sense. It's a graph. The situations I'm complaining about has nothing to do with coordinates.
-
@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'. -
hawkes15697y// list of customers from the database
global List<Customer> x = gcl();
// TODO documentation
List<Customer> gcl() { ... }
αβΈ ΚΜ―βΈα -
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...
Related Rants
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.
undefined
standards
not clean code
naming
coworkers