Hacker News new | past | comments | ask | show | jobs | submit login

I disagree, depending on the context. Data is an acceptable variable name to refer to binary blobs that don't have a type, eg, this is roughly the low level class that holds data that I'm streaming in (files may either be in a pack file or downloaded while the game is played):

class packFile { var name:String; var location:String; var downloadPriority:Int; var data:Array<Byte>; }

There may be a better name than data, but I can't think of one off the top of my head, and it's certainly not a bad one.




Another example: in my work group, "data" specifically means "measurements made in the real world." Numbers generated by a computer simulation don't qualify. So in our code, "data" could be a perfectly meaningful variable name.

Personally, the worst variable name I've ever seen was "C". This was a vector of concentrations. Unfortunately, the language was Fortran-77-- where a "C" in column 1 indicates a comment line.


Wow, I think you actually may have won. That's a terrible name for a variable given the context. You would probably have nightmares for years after maintaining a project like that :)


I generally go with buf for a buffer containing unstructured data. It seems a bit more logical, although I'm not really sure why.


It's more informative. "buf" gives you a few more bits of information about the source and purpose of the data than "data" does.


Similarly, when dealing with a small finite number of data, an integer at the end makes sense too.

For example: int add(int operand1, int operand2) { return operand1+operand2; }




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: