3 ms·
I disagree. 's' has no meaning by itself, which means that you have to read all of the context surrounding 's' into your short term memory just to gain any und
by evilduck 13y ago
I disagree.
's' has no meaning by itself, which means that you have to read all of the context surrounding 's' into your short term memory just to gain any understanding of the single line you may be interested in. That's slow and more work than necessary most of the time.
Also, naming things is a habit and a style. Short variable naming leaks out of 4 line methods into any 40 and 400 line methods you may eventually write, and it leaks into the ABIs/APIs of your application. I've rarely seen any code that would use 's' appropriately in a 4 line method that wouldn't hesitate to use it everywhere else inappropriately.
- asdasf 13y ago>'s' has no meaning by itself That is exactly the point. It is just a string. That is the entire context of the variable, there is no more insight to be gained. The more generic a function is, the more generic the argument is, and thus the less context exists to be put in the name. Naming it "thisIsAStringJustSoYouKnowTwiceThatItIsAStringLikeTheTypeAlreadyToldYou" instead of "s" does not provide any benefit. >I've rarely seen any code that would use 's' appropriately in a 4 line method that wouldn't hesitate to use it everywhere else inappropriately. You should read more code. Both go and haskell have tons of examples, as this is standard practice in those languages.
- deleted 13y ago[deleted]
- jff 13y agoOh come the fuck on. At least to anyone who's written a C program, using "s" for a string argument is absolutely clear. Read the man pages for pretty much every goddamn string function in the standard library; strlen, strcmp, whatever, they call name them either "s" or "s1", "s2" if there are multiple strings. Maybe we should do strlen(const char* theStringThatIsBeingMeasured), that's a lot clearer. Maybe we should expand char to character, and strlen to stringlength, because it might not be clear enough.
- bsg75 13y agostringlength may not be clear enough. Need some underscores in there to separate the terms, maybe a prefix to indicate the type, and a url to the parameter documentation.
- pkinsky 13y agoDon't bring underscores into this, underscores scan quicker and are aesthetically pleasing! http://ieeexplore.ieee.org/xpl/articleDetails.jsp?tp=&arnumber=5521745 http://ieeexplore.ieee.org/xpl/articleDetails.jsp?tp=&arnumb...
- evilduck 13y agoWhy are you guys stuck on 's' definitely being a string? It could just as easily be a struct or anything else imaginable, in which case, you're back to not knowing anything about it from the name 's' without going to look it up. You can contrive simple examples about basic data types all you want, the simple cases and built in types are precisely where it's not a problem. Go read the src for Go's Unicode package as an example, you get 60 line methods with stuff like 't1' used all over the place and the value of t1 is assigned pages away from where it's actually used.
- asdasf 13y ago>Why are you guys stuck on 's' definitely being a string? Because that is the example I used. >It could just as easily be a struct or anything else imaginable, in which case, you're back to not knowing anything about it from the name 's' without going to look it up. If there were more information that could be conveyed, then it wouldn't be named "s". That is the entire point.