0
rox79
4y

What kind of developer you are? What you write first LHS or RHS while assigning values?

Step 1: a+b
Step 2 : const a = a+b;

or
Step 1: const a;
Step 2 : const a = a + b;

Comments
  • 11
    Those are... both invalid.
  • 6
  • 7
    ;b + a = c tsnoc
  • 1
    From left to right unless I know the RHS but I have to think what it will be called.
  • 0
    @electrineer reft to light text maybe?
  • 0
    Hm. Evaluation order of operands can be important in programming languages.

    But I'm confused as it seem the author meant mathematical equations....

    Math bad!
  • 0
    @IntrusionCM oor s/he just meant what part you THINKED first, however the result of writing is always the same.

    If that's the case, I work from in to out.
  • 0
    @electrineer me too prefer this way but the course I took he evaluate the expression first then assign it to a variable which seems little odd to me :P
  • 0
    @melezorus34 I'm just asking some took evaluate the expression first then assign it to variable. But some are like me first write the variable then assign value to it ;)
  • 0
    @rox79

    Your example is very confusing.

    I'd expect it to not work at all.

    a = 1;
    b = 2;

    const c;
    const c = a +b;

    vs

    const c = a + b;

    ?

    If yes, it would be declaration before usage, which was common in (now) ancient C.
  • 0
    Just to clarify: I wanted to give an example for the pattern....

    Not saying that it is done like that in C.

    Most languages will not like a redeclaration of a const variable let alone const override... So it's still wrong, but might be a step to an better example
  • 1
    @IntrusionCM I guess only @electrineer understand what I am trying to say. Rest are looking at code :P
  • 1
    @rox79

    Okay. You mean steps as in several steps for writing a single line of code?
  • 0
  • 2
    This rant is a fucking crackhead straight from the dumpster

    @-ANGRY-STUDENT-
  • 0
    @rox79 Then, I work from in to out, a.k.a. RHS
  • 0
    @melezorus34 eww confusing ;)
  • 1
    @rox79 *subtle hint*: this was very hard to guess... ;)

    In that case... You don't want to watch me programming

    Since I usually know what I want to achieve I might be hopping from File to file changing a lot of things in random order...

    The IDE mostly sits terrified in the corner screaming it makes no sense at all.

    Usually I'm switching between both styles, depending on wether I'm having something in the clipboard for pasting or leaving a note to myself for later
  • 2
    neither, i'm more of an "expanding expression tree" kind of guy.

    i mean, i can either write the whole thing in order, or when i can't, i do something like:

    1. newPosition = swipeEnd - swipeStart;

    2. newPosition = (swipeEnd - swipeStart).normalized * movementDistance;

    3.
    //this dude gets added as class property
    public float movementDistance;

    //these guys are in a function way down
    newPosition = transform.position + (swipeEnd - swipeStart).normalized * movementDistance;

    and then i realize it's going to be teleporting me through walls because of course, so

    4.
    //this dude gets added as class property
    public float movementDistance;

    //these guys are in a function way down
    float actualMovementDistance = movementDistance;
    RaycastHit rh;

    if(Physics.Raycast(..,..,.., out rh){
    actualMovementDistance = rh.distance;
    }

    newPosition = transform.position + (swipeEnd - swipeStart).normalized * actualMovementDistance;

    so... yeah... let's call it an "expanding expression tree" style =D
  • 0
    Lets just think that was on purpose.
  • 0
    From top to bottom
  • 2
    a+b
    ALT+ENTER
    "Introduce local variable"

    Intellij FTW
  • 3
    Is there anyone who does the first?

    I write it left to right, like a normal sentence

    int c = a + b;

    I want to be able to write it like I read it: "Integer c is going to equal a plus b"

    I think about my code as if its written in a normal language... Or maybe reverse? I think of the code as if it was natural to speak in its language?

    Dunno, but Im very language oriented, so left to right, top to bottom
Add Comment