 |
 |
 |
The Official Hentaiverse Chat, Post your random thoughts or theorycrafts about HV |
|
Mar 23 2018, 10:58
|
Sapo84
Group: Gold Star Club
Posts: 3,332
Joined: 14-June 09

|
QUOTE(DJNoni @ Mar 23 2018, 07:13)  if you describe in what the function does, we can help you to find a name that makes sense.
I don't think it's a language problem, it's inherently difficult to name variables and functions in coding. There are only two hard things in Computer Science: cache invalidation and naming things.I would honestly consider writing very long and descriptive variables/function names and then minify the output if the bundle size is too big. Pretty much all decent JS editors will handle the autocomplete anyway so there are no gains in having short names.
|
|
|
Mar 23 2018, 11:22
|
Ass Spanker
Group: Gold Star Club
Posts: 4,177
Joined: 25-July 12

|
QUOTE(sssss2 @ Mar 23 2018, 13:33)  The hardest part of coding is naming variables and functions. at least for me (IMG:[ invalid] style_emoticons/default/sad.gif) CODE var x1; var x2; var x3; var x4; ....
|
|
|
Mar 23 2018, 11:27
|
Superlatanium
Group: Gold Star Club
Posts: 7,603
Joined: 27-November 13

|
QUOTE(as013 @ Mar 23 2018, 09:22)  CODE var x1; var x2; var x3; var x4; .... [come back a month later] "What the heck is this variable I used representing?" (additionally 10x worse if anyone other than you has to understand it) (also, `const` is love) This post has been edited by Superlatanium: Mar 23 2018, 11:28
|
|
|
|
 |
|
Mar 23 2018, 11:37
|
Scremaz
Group: Gold Star Club
Posts: 24,304
Joined: 18-January 07

|
QUOTE(Sapo84 @ Mar 23 2018, 09:58)  I would honestly consider writing very long and descriptive variables/function names and then minify the output if the bundle size is too big. Pretty much all decent JS editors will handle the autocomplete anyway so there are no gains in having short names.
this, hands down QUOTE(as013 @ Mar 23 2018, 10:22)  CODE var x1; var x2; var x3; var x4; .... it doesn't work this way. even f it works (hell, you can even name your variables "Mickey.Mouse" or "Donald.Duck", if it's for that), but at a certain point you have to think about maintenance, because: QUOTE(Superlatanium @ Mar 23 2018, 10:27)  [come back a month later] "What the heck is this variable I used representing?" (additionally 10x worse if anyone other than you has to understand it)
if even comments may not be enough to understand what to do, how can you remotely think about doing a decent code if your variables aren't named in a fitting way? logical errors are always behind the corner of a proper code, letting apart if you manipulate the wrong variable because the name is not functional...
|
|
|
|
 |
|
Mar 23 2018, 12:18
|
Ass Spanker
Group: Gold Star Club
Posts: 4,177
Joined: 25-July 12

|
QUOTE(Superlatanium @ Mar 23 2018, 17:27)  [come back a month later] "What the heck is this variable I used representing?" (additionally 10x worse if anyone other than you has to understand it)
(also, `const` is love)
What's the pros and cons of using const over var? I have always used var
|
|
|
|
 |
|
Mar 23 2018, 12:28
|
Sapo84
Group: Gold Star Club
Posts: 3,332
Joined: 14-June 09

|
QUOTE(Scremaz @ Mar 23 2018, 10:37)  if even comments may not be enough to understand what to do, how can you remotely think about doing a decent code if your variables aren't named in a fitting way?
Real production code CODE public class GraphDataLight : GraphData { public string Id { get; set; } }
(if you're not familiar with the synthax it would be similar to GraphDataLight extends GraphData, if you're not familiar with ES6 you're out of luck because I suck at using prototype chain and I'm not gonna bother) To this day I still can't quite understand wtf my coworker was smoking when he wrote that (I hate that we stopped using pull requests because I would have rejected that with the force of a thousand suns). @as013: you can't modify a constant value, using let and const makes understanding the code easier, different hoisting which is imho more intuitive because: CODE console.log(wtf); var wtf = "hi";
just logs undefined while CODE console.log(wtf); const wtf = "hi";
logs "ReferenceError: can't access lexical declaration `wtf' before initialization"
|
|
|
|
 |
|
Mar 23 2018, 17:56
|
Superlatanium
Group: Gold Star Club
Posts: 7,603
Joined: 27-November 13

|
QUOTE(as013 @ Mar 23 2018, 10:18)  What's the pros and cons of using const over var? I have always used var Always use const, rarely use let when you need to reassign the variable, never use var. (then, generally use Babel to automatically transpile down to ES5 if you need to support IE) The main reason const is so great is that it makes code a lot easier to read at a glance. If you see CODE const { id } = { someElement }; (30 lines of code) const newStr = `The element was ${id}!`; When you see the `const`, you know that its variable will never be reassigned: once you see said variable defined, you know exactly what it will be when you see it elsewhere in the script without reading all the lines in between to check to see if it ever gets reassigned. You don't have to read those intervening 30 lines to be sure of what `newStr` will actually come out to be. The other benefit of `const` (and `let`) is that it has block scope, which is useful for a similar reason: it has block scope, not function scope, so it's easier to tell at a glance where it'll be in scope. You don't have to search for the nearest ancestor function definition, you simply need to look at the indentation. Pretending for the moment that `for` loops are OK to write, which they generally aren't: CODE for (var i = 0; i < items.length; i++) { // do stuff with items[i] } // some lines of code... < something referencing `i`, which is almost certainly a mistake> This won't throw an error if you use `var`, but it will if you're using `let`. `var` also has hoisting problems, unlike `const` and `let`. If you accidentally reference a variable before you actually initialize it, you want the interpreter to throw an error immediately, since it's almost certainly a logic error. IMO `const` is one of the greatest features of ES2015, and given its many features, that's saying a lot. This post has been edited by Superlatanium: Mar 23 2018, 18:02
|
|
|
|
 |
|
|
 |
|
Mar 23 2018, 21:55
|
KitsuneAbby
Group: Catgirl Camarilla
Posts: 7,572
Joined: 12-July 14

|
QUOTE(Sapo84 @ Mar 23 2018, 09:58)  I don't think it's a language problem, it's inherently difficult to name variables and functions in coding. Utterly wrong. Those who have a hard time finding names to their vars, procedures, classes, whateverelse have a serious issue when it comes to organize their code (and work) properly. It being widely common within the ranks of "coders" around the world doesn't make it a rule. Someone who thinks properly not only while coding, but also before coding, doesn't face this kind of issues. At worst such a person faces bugs, has a hard time finding out how to reach his goal (organization-wise), or faces technical limitations. But nothing like finding proper names to vars, procedures, classes, because he knows exactly what he wants to get, how to get it, and how to do things the appropriate way with the means he has at hand. Pissing code doesn't make one an actual scripter/programmer/giveitthenameyouwant. Having the proper knowledge, culture, work methods, thinking process does. If one faces naming issues, then the only thing it means is that he is doing something wrong somehow. Most likely having no actual idea of what his variable stores, what his procedure is supposed to do, or what the instances of his class are supposed to represent/do. The worst is that this kind of issues often doesn't come alone: bad indentation, code being repetitive, hard to read (or to decipher...), hard to understand, unnecessary comments or lack of useful comments. TL;DRIf you have a hard time naming your vars, you're doing something wrong. And when it happens, you should take a step back, take a deep breath (or even a 5/15 minutes break to have a smoke/coffee, clear your mind, chat), and ask yourself "what am I even doing?"
|
|
|
|
 |
|
Mar 23 2018, 22:21
|
Noni
Group: Catgirl Camarilla
Posts: 13,220
Joined: 19-February 16

|
QUOTE(decondelite @ Mar 23 2018, 20:55)  Utterly wrong. ....
Boy, am I glad I don't do coding for a living!
|
|
|
|
 |
|
Mar 23 2018, 22:37
|
Sapo84
Group: Gold Star Club
Posts: 3,332
Joined: 14-June 09

|
QUOTE(decondelite @ Mar 23 2018, 20:55)  Utterly wrong.
That's why the second chapter of Clean Code: A Handbook of Agile Software Craftsmanship (pretty good book btw) is dedicated to "Meaningful names". That's also why the quote I posted earlier has been repeated by many important personalities throughout the years (the likes of Martin Fowler and many other coders that actually wrote the patterns that most coders use nowadays). Naming being easy it's also why there is still no agreement on how you should call the table in a RDBMS, people are evenly divided by the "singular name" camp and the "plural name" camp. Both have merits, not everything is so simple that you can decide without making compromises. So you need to pick names that relay the correct meaning, are consistent with the project you're working on (and possibly other 5-6 people are too), are consistent with the platform/framework/language you're using and have no noise. And you need to think that while they are obvious to you they may not be equally clear for another coder 2 years from now. Maybe the method you're writing would be better extracted in another class/interface to add more context and so on. Writing code is also somewhat like telling a story, if you say that you shouldn't have trouble choosing the words you're using you're either a genius at doing that or never really cared that much. Btw, I use plural names for DB tables and singular names for the entities in the code, that was the approach I choose after a ~15 minutes read on SO and a look on how MS handles the names of the tables in their own products (like ASP.NET Identity default tables). I could have chosen singular or plural without much though, it would have been a 99% correct choice which would have been perfectly understandable by everyone, but I personally prefer spending times valuing all possibilities even if it may be a waste of time than regretting it later. Priorities, I guess.
|
|
|
|
 |
|
Mar 24 2018, 00:35
|
KitsuneAbby
Group: Catgirl Camarilla
Posts: 7,572
Joined: 12-July 14

|
Not having trouble chosing names != not thinking about them
I'm not going to step in the "naming standards" mine field. That's a troll-food topic.
|
|
|
|
 |
|
Mar 24 2018, 02:34
|
Sapo84
Group: Gold Star Club
Posts: 3,332
Joined: 14-June 09

|
Well, I obviously wasn't implying coders take 1 minute to decide each variable name, that would be stupid. But the mental fatigue of choosing unique, meaningful and low-noise names is certainly not to be underestimated (it's certainly one of the most tiring things of refactors and I found it more subtle than applying patterns or removing duplicated code since with enough experience you can feel how to clean up the code, names are always somewhat project-specific and need a bit of thinking).
It also heavily depends on what you're working on, if you're writing an emulator I doubt names are even remotely the focus of the developers, if you're doing fetching data -> transforming data -> printing out in pretty html for 50 pages it's pretty much boredom + making sure that 2 years from now the next developer fixing your bugs will understand what you've written.
|
|
|
|
 |
|
Mar 24 2018, 05:37
|
Honeycat
Group: Catgirl Camarilla
Posts: 61,592
Joined: 25-February 07

|
Holy shit, and I thought arena rounds were mind-numbing.
|
|
|
Mar 24 2018, 06:26
|
sssss2
Group: Gold Star Club
Posts: 3,963
Joined: 11-April 14

|
I'm testing Coupon Clipper script. If anybody needs potions or scraps, please send me MM, using this format. (need to attach credits) QUOTE 10x energy cell @180 20x scrap cloth @90 30x mana potion @90
* For HVUT user: use [ATTACH from TEXT -> CALC] function.
|
|
|
Mar 24 2018, 11:26
|
chjj30
Group: Catgirl Camarilla
Posts: 10,914
Joined: 5-January 14

|
QUOTE(sssss2 @ Mar 24 2018, 12:26)  I'm testing Coupon Clipper script.
If anybody needs potions or scraps, please send me MM, using this format. (need to attach credits) * For HVUT user: use [ATTACH from TEXT -> CALC] function.
Sent a MM for buying energy cell and mana potion. I don't know if I should write a special Titel.
|
|
|
Mar 24 2018, 14:44
|
sssss2
Group: Gold Star Club
Posts: 3,963
Joined: 11-April 14

|
I had decided to quit HV at the end of last year. But HVUT, a parting gift, prevented me... Recently I dreamt of being holy mage, but it almost failed. It's time to really quit...? Yep, I know I'm always grumbling (IMG:[ invalid] style_emoticons/default/sad.gif) This post has been edited by sssss2: Mar 24 2018, 14:44
|
|
|
Mar 24 2018, 15:03
|
yami_zetsu
Group: Gold Star Club
Posts: 2,687
Joined: 25-February 13

|
QUOTE(sssss2 @ Mar 24 2018, 07:44) 
Recently I dreamt of being holy mage, but it almost failed.
cool, another person to compete for gear (IMG:[ invalid] style_emoticons/default/cry.gif)
|
|
|
Mar 24 2018, 17:09
|
Noni
Group: Catgirl Camarilla
Posts: 13,220
Joined: 19-February 16

|
QUOTE(sssss2 @ Mar 24 2018, 13:44)  Recently I dreamt of being holy mage, but it almost failed. It's time to really quit...? Yep, I know I'm always grumbling (IMG:[ invalid] style_emoticons/default/sad.gif) Your staff looks nice, though. Is your gear not good enough to play? Which of your sets is stronger?
|
|
|
Mar 24 2018, 23:58
|
KingArtson
Group: Gold Star Club
Posts: 2,564
Joined: 22-December 12

|
QUOTE(sssss2 @ Mar 24 2018, 14:44)  I had decided to quit HV at the end of last year. But HVUT, a parting gift, prevented me... Recently I dreamt of being holy mage, but it almost failed. It's time to really quit...? Yep, I know I'm always grumbling (IMG:[ invalid] style_emoticons/default/sad.gif) Do not quit! I need your LHOH, but I need a couple more months to collect the right amount of credits (IMG:[ invalid] style_emoticons/default/laugh.gif)
|
|
|
2 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
|
 |
 |
 |
|