Welcome Guest ( Log In | Register )

2611 Pages V « < 2216 2217 2218 2219 2220 > »   
Reply to this topicStart new topic
> The Official Hentaiverse Chat, Post your random thoughts or theorycrafts about HV

 
post Mar 23 2018, 10:58
Post #44341
Sapo84



Deus lo vult
********
Group: Gold Star Club
Posts: 3,332
Joined: 14-June 09
Level 500 (Ponyslayer)


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.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Mar 23 2018, 11:22
Post #44342
Ass Spanker



Professional Ass Spanker
********
Group: Gold Star Club
Posts: 4,177
Joined: 25-July 12
Level 500 (Ponyslayer)


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;
....
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Mar 23 2018, 11:27
Post #44343
Superlatanium



Dreaming of optimizing the system
**********
Group: Gold Star Club
Posts: 7,603
Joined: 27-November 13
Level 500 (Godslayer)


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
User is online!Profile CardPM
Go to the top of the page
+Quote Post

 
post Mar 23 2018, 11:37
Post #44344
Scremaz



A certain pervert. OT expert. Just dancing around in the game.
***********
Group: Gold Star Club
Posts: 24,304
Joined: 18-January 07
Level 500 (Ponyslayer)


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...
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Mar 23 2018, 12:18
Post #44345
Ass Spanker



Professional Ass Spanker
********
Group: Gold Star Club
Posts: 4,177
Joined: 25-July 12
Level 500 (Ponyslayer)


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
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Mar 23 2018, 12:28
Post #44346
Sapo84



Deus lo vult
********
Group: Gold Star Club
Posts: 3,332
Joined: 14-June 09
Level 500 (Ponyslayer)


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"
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Mar 23 2018, 17:56
Post #44347
Superlatanium



Dreaming of optimizing the system
**********
Group: Gold Star Club
Posts: 7,603
Joined: 27-November 13
Level 500 (Godslayer)


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
User is online!Profile CardPM
Go to the top of the page
+Quote Post

 
post Mar 23 2018, 21:17
Post #44348
Scremaz



A certain pervert. OT expert. Just dancing around in the game.
***********
Group: Gold Star Club
Posts: 24,304
Joined: 18-January 07
Level 500 (Ponyslayer)


it has been not-so-visible in the past few days, but for those interested in a P-tier Charged Gloves of Heaven-sent, i just pinned this thread: https://forums.e-hentai.org/index.php?showtopic=213683
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Mar 23 2018, 21:55
Post #44349
KitsuneAbby



Curse God of the Hentai Shrine
**********
Group: Catgirl Camarilla
Posts: 7,572
Joined: 12-July 14
Level 500 (Ponyslayer)


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;DR
If 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?"
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Mar 23 2018, 22:21
Post #44350
Noni



Hataraku Noni-sama
***********
Group: Catgirl Camarilla
Posts: 13,220
Joined: 19-February 16
Level 500 (Ponyslayer)


QUOTE(decondelite @ Mar 23 2018, 20:55) *

Utterly wrong.
....


Boy, am I glad I don't do coding for a living!
User is online!Profile CardPM
Go to the top of the page
+Quote Post

 
post Mar 23 2018, 22:37
Post #44351
Sapo84



Deus lo vult
********
Group: Gold Star Club
Posts: 3,332
Joined: 14-June 09
Level 500 (Ponyslayer)


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.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Mar 24 2018, 00:35
Post #44352
KitsuneAbby



Curse God of the Hentai Shrine
**********
Group: Catgirl Camarilla
Posts: 7,572
Joined: 12-July 14
Level 500 (Ponyslayer)


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.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Mar 24 2018, 02:34
Post #44353
Sapo84



Deus lo vult
********
Group: Gold Star Club
Posts: 3,332
Joined: 14-June 09
Level 500 (Ponyslayer)


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.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Mar 24 2018, 05:37
Post #44354
Honeycat



Extra Hissy
************
Group: Catgirl Camarilla
Posts: 61,592
Joined: 25-February 07
Level 500 (Godslayer)


Holy shit, and I thought arena rounds were mind-numbing.

User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Mar 24 2018, 06:26
Post #44355
sssss2



Veteran Poster
********
Group: Gold Star Club
Posts: 3,963
Joined: 11-April 14
Level 500 (Ponyslayer)


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.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Mar 24 2018, 11:26
Post #44356
chjj30



🦘跳海魔女🧙王世坚🌊
***********
Group: Catgirl Camarilla
Posts: 10,914
Joined: 5-January 14
Level 500 (Ponyslayer)


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.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Mar 24 2018, 14:44
Post #44357
sssss2



Veteran Poster
********
Group: Gold Star Club
Posts: 3,963
Joined: 11-April 14
Level 500 (Ponyslayer)


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
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Mar 24 2018, 15:03
Post #44358
yami_zetsu



not happy yet but almost maybe
********
Group: Gold Star Club
Posts: 2,687
Joined: 25-February 13
Level 500 (Ponyslayer)


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)
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Mar 24 2018, 17:09
Post #44359
Noni



Hataraku Noni-sama
***********
Group: Catgirl Camarilla
Posts: 13,220
Joined: 19-February 16
Level 500 (Ponyslayer)


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?
User is online!Profile CardPM
Go to the top of the page
+Quote Post

 
post Mar 24 2018, 23:58
Post #44360
KingArtson



Veteran Poster
********
Group: Gold Star Club
Posts: 2,564
Joined: 22-December 12
Level 500 (Ponyslayer)


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)
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


2611 Pages V « < 2216 2217 2218 2219 2220 > » 
Reply to this topicStart new topic
2 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
1 Members: Spyroflex

 


Lo-Fi Version Time is now: 3rd May 2025 - 13:28