Search Unity

Things I learned this week about coding.

Discussion in 'Scripting' started by dennik, Nov 22, 2020.

  1. dennik

    dennik

    Joined:
    Nov 23, 2011
    Posts:
    101
    1)Don't setup a computer to develop with, in one of the busiest rooms in the house (dining room next to kitchen in my case) Coding is like counting numbers. You get interrupted, you start from scratch.
    2) Write down plenty of notes and sketches to visualize what your code does, and better understand the logic you are implementing, and any flaws in it.
    3) Try to avoid "spaghetti code". (learned that term recently, as it described my coding style perfectly)
    4)Don't use logic statements in code unless you've mapped out every possible value or range of values you feed them, and how they will respond to those values. Don't, or you are in for a whole world of pain.
    5)Don't try to code or debug while tired.
    6) If you feel like you need a nap, your brain is no good so take a darn power nap.
    7)If you comment out a line to see if something will change, don't forget to uncomment it if nothing changes. (chances are you will break something else, forget you commented that line, and not realize why)
    8) Block THE WHOLE DARN INTERNET except for the scripting reference manual, while you are coding. Debugging is painful and your brain will do the best it can to procrastinate instead.


    If there is another comprehensive list of dos and don'ts I'd love to read it, but these are my own gems learning from my own stupidity.
    Anyway I hope this helps someone.
     
    mopthrow and Bunny83 like this.
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    • When you're stuck on something, rather than sitting and bashing your head against it, go take a walk, wash the dishes or do the laundry. Often you will have a Eureka moment while doing so, or solve the problem immediately after sitting back down with some fresh perspective.
    • Don't be afraid to ask for help. You won't look as stupid as you think you will.
    • Experiment. There's more than one way to do everything. Try new things. Challenge yourself with concepts that seem scary. They probably are easier than they seem once you try.
    • Break every problem down into small, manageable, "easy" chunks. This is the true secret to programming. Nobody truly solves hard problems. They find ways to break them down into a series of easy problems.
     
    Last edited: Nov 22, 2020
    Vryken, Olmi, Suddoha and 5 others like this.
  3. Owen-Reynolds

    Owen-Reynolds

    Joined:
    Feb 15, 2012
    Posts:
    1,998
    #5 is the opposite of common advice. It goes like this" "You've got 2-3 hours(*) of really good time to do development. Don't waste it. The rest of the day do easy stuff like debugging". Debugging is relatively easy since it can't screw anything up. Say you figure out the game sometimes doesn't detect victory because some ways of increasing the score forget to check. Maybe you can replace score+=5 with the correct call. But you can always make a note and fix it later.

    (8) 2-3 sounds low, but it's the same advice if you put 4-6