Wednesday, October 22, 2014

5am Challenge - Day 1 (officially...)

Even staying up a little later than I typically do, I still managed to force myself out of bed around 5:05 this morning. It's actually not so bad once you actually stand up for a minute or two and force yourself out of the comfort and warmth of bed. I let the dogs out as usual, grabbed a quick cup of coffee, and now time for a quick update before I dive back into my studies.

One thing to mention for those that have been following along... I've heard some great advice from other bloggers (about code) that I thought would be useful and I'm going to follow a similar format. That is, I'm really writing these for me as a refresher, and if I'm able to provide value for other readers great! The basic idea is that I can blog about things I learn, and it keeps a running record of documentation (or notes) on topics and problems I encounter. That way if I run into something similar down the road I can think to myself..."aha..I wrote a blog post about that way back when..." and search back and find my notes.

I'm getting to the point with code where I can start to read and understand, but it takes me longer to actually write or come up with my own code. It's very similar to learning a foreign language, like Spanish for example. I took a few years of Spanish in high school, and while to this day I can read certain things and understand the gist, it is much harder to listen and understand a native Spanish speaker, and even harder for me to form more than a very basic sentence that even a 4 or 5 year old would say.

I'm currently working on Ruby because I'm trying to get the syntax down enough so that I can implement my Data Structures in Ruby as well as Java. Java is a lot more rigid and you have to directly state certain things, whereas in Ruby you can write less code and accomplish the same thing. Ruby reads a lot like pseudo code (very similar to plain English just explaining on how a block of code would work without worrying about exact syntax).

For example, here is one simple line of Ruby that anybody can probably guess what it does:

    def greeting(name)
          puts "Hello #{name}!"
    end

   greeting("World")


As you might have guessed, the output of this simple Ruby script would read "Hello World!"

I spent about 2 hours yesterday morning and another 30-45 minutes yesterday evening both working through the CodeAcademy (www.codeacademy.com) Ruby Tutorial as well as updated my first problem I'm trying to implement in Ruby. I at least got the first part working which is really just an Array class to construct my arrays from. I got to the Object Oriented section of the Ruby tutorial which really helped because it also reminded me of Instance variables and what scope I need to provide which variables. I'm pretty sure the reason my initial solution was not working was for this very reason. I was trying to call a variable from a different method that did not have access to that variable. Here is the little bit of code so far, but I should get a lot more of it done today:



Yes it doesn't look like much for over 2 hours, but it was more studying through CodeAcademy and then refactoring my code to make this first part work, so I'm proud of it! That's it for today...time for some studying!





No comments:

Post a Comment