Wednesday, September 30, 2015

Fastest Way to Learn Ruby

  Hello, everyone!

  I have been spending a lot of time coding these last couple of days, so I am pretty happy about that.

  Last Saturday, I drove up to Washington DC for a Ruby Meetup group, that meets every other Saturday for "what they call" a hack-a-thon. It was my first time participating in a meetup group, so I was not sure what to expect. I had a very positive experience. This particular meetup was basically an open lab session. Everyone came with their laptops and worked on their projects for 4 hours or so. It was great for a lot of reasons. I was there for 4 hours, so for 4 hours I pretty much was writing code. It is difficult to do that at home, because there are always distractions, and it is almost impossible to find a 4 hour block of time to just sit down and code. It was also great, because when I was stuck, there were several people who were very knowledgeable at Ruby sitting next to me, willing to dig into my code and help me out with it. I was working on my game for Chapter 45, and the host of the meetup spent about two hours with me, going though my code, giving me ideas, showing me how I can optimize my code, explaining a lot of new concepts to me on the way. I also asked questions about the previous chapter on hashes that I had difficulty with, and he explained some parts of the code that I had trouble with.

  I can honestly say that in two hours with him, I learned more than I do in a week of self-studying! It was incredible. I picked up a lot of little tips on how to work with irb, understood some important concepts that I was struggling with, etc. It was definitely worth the drive to DC, and I am looking forward to going there again, and going to other Ruby meetup groups in the area.

  If you are out there, trying to teach yourself code, look up local meetups that you can go to in your area. It might accelerate your learning and you might meet some interesting people.

  It is starting to slow down at work for me, as winter is approaching, so my plan is to double my study hours by November 1.

  I can't wait to finish Zed Shaw's book, and see what I can dive into next!

  The goal is to have Chapter 45 complete by this weekend!

  Thanks for reading, and til next time.

 -Andrei

Friday, September 25, 2015

Back to blogging

  Heeeello, everyone!

  It has been a couple of weeks since my last post. I have been somewhat busier than usual at work, but I am back to normal now. I am planning on posting consistently again. Realistically, it does not take long to make a blog post, but I have not been coding as much, and it felt like I did not have much to share.

  Anyway, in the last weeks, I did work through Chapters 39 to 44 of Shaw's "Learn Ruby the Hard Way".

  Chapters 38 through 40 covered hashes, classes and modules, and Chapter 41 introduced the concept of "object oriented programming".

  I must say Chapter 41 had me really stuck, considering that I was just blowing though the material previously. When I was trying to wrap my head around the exercise code, it really felt like I accidentally skipped a couple chapters. This is  --> the code <-- I am having difficulty with. I understand what it does, I just don't 100% understand HOW it does it. You can see my #comments in the code where I am having difficulty. What I ended up doing is just submitting to the idea that I do not understand it all the way, and moving to the next chapter. I will give it some time, work through some more material, and come back to this equipped with more knowledge to hopefully understand it better.

  Chapter 42 reinforced the differences between classes, subclasses and objects. After the brutality of the previous chapter, the code seemed very easy, and I think I understood it pretty well.

  Chapter 43 was fairly difficult but really cool. Mr Shaw goes through a process of analyzing and designing "object oriented" code, which basically has you building code from "top to bottom". He walks through his thought process of building code from scratch from an idea to the final code.

  Chapter 44 describes the difference between class inheritance and composition, and briefly touches on when one is preferred over the other.

  Chapter 45 is all about building another game, and that is what I am working on right now.  I have the game designed already, and I am writing small snippets of code, and testing everything to make sure it works how I want it to, before I start building the actual game code. It will be a small dungeon-crawl style game, where you fight monsters, improve your character to face the boss in the end of the game. There are some things I want the game to do, that I have NO idea how to do it in code, so I am planning on learning a lot during this project!

  This post has gotten a little too long since I have last two weeks of "not posting" to catch up on. Thanks for following my blog, and thanks for reading!

  I have some exciting things planned this weekend, so I will talk about that in my next blog in a couple of days, and I will talk through some code examples that I am working on for the game I am working on.

  Have a great weekend, everyone!

 - Andrei
 

  

Monday, September 7, 2015

Play my Ruby game!

  Hello, everyone!

  Still coding here, and I just finished Chapter 36 of Mr. Shaw's book. The Chapter's assignment is to make your own text based game. I found the website where I can upload Ruby code, and you can play my game right in your web browser! I would love for you to play my game and try to beat it! It is a pretty simple "escape room" style game. It took my wife less than 5 minutes to win! :)

  Click Here To Play my game! When the window finishes loading, Click "Run" on the top right corner to execute the code. Also it is a lot easier if you resize the window so you can see less code and more of the game window. Drag and drop the divider in the middle to the left, so that your black screen is wider. Just read the text on the right, type in your commands and enjoy the adventure  :)

  Let me know if you liked it, or hated it! Or if you run into errors, or you are stuck :)

  It was pretty exciting to finish this large chunk of code, and to have it all work! I had a lot of fun coding this game.

  Here is the raw version of the code on github: https://gist.github.com/e3a8244e1206ee455dd8

  This repl.it website is pretty neat. You can code right in your web browser, and run the script. Pretty handy if you are a beginner!

  Later!

  -Andrei

  

Wednesday, September 2, 2015

Time to sort it all out...

  Hello, everyone!

  For the last couple of days I have not been able to get as much as studying done as I hoped, but I am done with first 10 chapters of Chris Pine's book. The chapter 10 exercise was the most challenging so far. I needed to write a script that asks the user for any number of words, gives all those words back in alphabetical order, preserving capitalization and keeping all the duplicates, and then shuffles all the words and gives them back in random order. The challenge of the exercise is that you cannot use any built in methods for it (like .sort). So I had to write the sorting script myself.

  The biggest challenge to me is to "solve" the exercise in English first, to figure out "how" I want the code to work. After I have an idea of how the code "should" work, writing it down in Ruby is just a matter of getting through all the error messages :)

  Here is how I solved it: Sorting Challenge

  I started working through Zed Shaw's Learn Ruby the Hard Way book, and I am up to chapter 15. The first 10 chapters were easy, but it is picking up difficulty fast.

  That's all for now!

-Andrei