Monday, May 26, 2014

Things Remembered/Know The Rules

Well, howdy! Or, rather, hello netizens. Sorry, I got a little Southern there. For those that don't know, netizen: a person who actively uses the internet especially in a proper and responsible way. The more you know. So, today I'm going to talk about some things that have made me stumble for stupid/crazy simple reasons. There are two main issues that I've come across. But first! I'm going to make coffee. Good thing this isn't a live stream. Now that ten minutes have passed for me and about a second for you, I'm back with coffee and sustenance. Le Music De Goog(read Google Play Music) is going and I'm ready. Time to plug in and plug away!

The biggest thing that gets my metaphorical goat is when your code looks like it's correct, there aren't any errors or anything like that, and it still doesn't return the result that you want. for instance: nested if statements. If you don't do them the right way, they will ignore entire sections of the code. For example:
<script type = "text/javascript">
var artist = "Foo Fighters"
var song = "Walk"

if(artist != "Foo Fighters"){
    alert("You don't like 'em, eh?");
      if(song == "Walk"){
        alert("nice choice");
      }else{
        alert("Too slow for you?");
      }
  }else{
    alert("Nice!");
  }
</script>

While this looks like it is correct, notice that the first if statement has a != that means does not equal. But the variable artist does equal "Foo Fighters" so it has to go to the end of the script to use alert("Nice!"); which means that the second if statement gets completely ignored. However, if the artist variable didn't equal "Foo Fighters" you'd be fine. So, it just calls for a little preexisting knowledge about your variables. Because if you don't know what's going on, your code will soon get really messed up and you won't know why because it all looks fine. Makes for debugging very annoying when you find out that you just had things in the wrong order, or something. The worst is when you spend hours trying to fix your code and it turns out that you're missing a period, or something like that. And if you haven't had this happen, it will. Don't worry.

Another thing that will mess you up is not knowing the rules. And the rule that doesn't get talked about too much, is that you can't name a variable with a number. So, var 1 ="hi" wouldn't register. It just sits there and does nothing. I'm not saying I've done this(totally have),but if I had(which I did) then I would tell you that it's annoying to look up the problem and it just makes you realize what a newb you are. 

So, there we have it, some things to watch out for in any language. 
1. Know the order in which things are read and run.
2. Know the rules.
3. Know that you'll mess up and don't be afraid of it.

And with that, I'll go and finish listening to +Jupiter Broadcasting because those guys are awesome.
See y'all on Wednesday!



 --Martin