Wednesday, October 28, 2015

Coding for 8 hours straight and staying focused

  Hello, everyone!

  Last Saturday I was supposed to go to a Ruby meetup in DC that was cancelled last minute. So I thought to myself, "well, I was supposed to spend 3 hours driving to DC, spend 2 hours at the meetup, and 3 hours driving home. How about I spend 8 hours on studying instead?".  Well, I did. Should you do it? Do I want to do it again?

  I have a difficult time focusing at home, when I try to sit down and study and/or code. My wife tries to be as mindful as she can when I am buried into my laptop, but with her cooking in the kitchen, my dog barking,  our bird chirping, house chores, TV on in the next room, the laundry buzzer going off, etc etc it is not easy to concentrate.

My dog Zoe especially insists on supervising my studying,
and she wants to make sure that I am aware that she is here for me in case I need anything.
Anything at all!!!!

  Well, I did find another trick that has been working for me. Lately I have been "running away from home" to study. After work, I come home, walk the dog, say hello to the Mrs, and then go study somewhere else for 2-3 hours. My locations of choice are coffee shops with good wifi. I get me a cup of coffee, put on my headphones and study. Zero distractions. :)

  So last Saturday, I went to my local Panera Bread in the morning and spent 8 hours studying. I had breakfast and lunch there. I was pretty tired but it was productive 8 hours. I did Chapters 47 and 48 of "Learn Ruby the Hard Way", Chapters 11 and 12 of Chris Pine's "Learn to Program" and worked a little on a couple of scripts I am writing as side projects. It felt really good to knock those chapters of my to-do list, and move forward.

  I mentioned it before in my blog, but when I code for more than 2 hours, the Pomodoro Technique is what really helps me stay focused. Basically, I study for 25 minutes until the timer goes off, and then I have a 5 minute break (where I do something totally unrelated to give my mind some rest: browse Facebook, check my text messages, watch a cat video on youtube...). Once 5 minutes are up, it is back to laser-focused studying for next 25 minutes without any distractions. It really helps me out, and I don't get burned out or tired. It has really changed the way I study.

  So, coding for 8 hours straight... Do I want to do it again? Heck, yes. I loved getting so much stuff done in one day, and seeing so much progress. I am looking forward to when I can schedule another power study day!

  Should you do it? That is something that you might have to decide for yourself, but it sure is a great way to get some of your projects done that have been on your back burner.

  Last piece of advice in case you do. Make sure you do a nice physical activity to get your heart rate up after you spend 8 hours staring into your laptop (go for a walk, for a jog, for a bike ride). What a satisfying way to end a super productive day!

 Have a great day, everyone, and thanks for reading!

 -Andrei
  

Thursday, October 22, 2015

Kicking studying into high gear

  Hello, everyone!

  This is a pretty exciting time for me. I live in a seasonal town, and starting Monday, it will slow down a lot for me as far as work goes, so I should have a lot more free time. I am planning on kicking up my study hours up a notch. I will try to aim for 5 hours a day. We will see how that goes.

  My Rails study group seems very promising. We already had one Google Hangout where we all "officially" introduced ourselves to each other, and talked about our plans for this study group. We will try to do one chapter a week, and talk about it on Mondays. There are exercises in the end of the chapter, and each person has been assigned an exercise that he will present to the group, and talk through solving it.

  I have been attending Ruby meetups as well. I am going to another one on Saturday in DC, and I am even scheduled to give a talk in an upcoming Ruby meetup in Baltimore, MD on November 10th! That's right, I volunteered to give a talk. I have never given one before, so I am really nervous and excited. I still have some time to prepare. My talk will be geared towards beginners (obviously). I think it would be a great experience and I will learn a lot from it too. I have to have a solid understanding of everything I will be attempting to present, organize my thoughts, and reword the material in an easy to understand manner, plus also hopefully be able to answer questions.

  I also purchased "The Well-Grounded Rubyist" By D. Black. It has really good reviews, and I am looking forward to reading it to supplement my learning.

  Still working on "Learn Ruby the Hard Way",  I really want to finish it but it is going pretty slow. I am stuck on the chapter that teaches you about writing test scripts, and I am having difficulty making tests for my own programs. I need to spend more time on it...

  That is all for now,

  Have a great weekend, everyone!

 - Andrei

  

Sunday, October 11, 2015

Two months coding journey summary

  Hello, everyone!

  Another week is coming to an end, and today is my two months "anniversary" of learning code.  Happy code-a-versary to me! :) Not that it means that much, but I feel like I have made considerable progress in 60 days. Sixty days ago, I learned how to code my first puts 'Hello, world!' program.  And today I wrote a script that reads a .txt file that contains a list of URLs, sends a request to each one, and emails the results of all the URL checks. (I will be talking about that script later in my blog).

  Here is a blueprint of how I studied with the resources I used. It might prove useful for those starting to learn code.

  In the last two months I have:

 - installed brew, ruby, rails, git on my computer (Link)
 - learned the basics of command line (Learn Command Line the Hard Way)
 - learned the basics of Git (Codeschool)
 - learned the basics of HTML and CSS (Learn How to Program)
 - some more HTML and CSS basics (General Assembly Course)
 - completed first 10 chapters of C.Pine's "Learn to Program" (e-Book or you can buy it on Amazon)
 - completed first 45 Chapters of Z.Shaw's "Learn Ruby the Hard Way" (e-Book)
 - started Hartls Rails Tutorial (Rails Tutorial)

 Whew, it has been a busy two months! And a lot more studying ahead! :)


 Here are some tips that I can offer to anyone who is learning code:

  - Avoid jumping around between websites and resources. Especially if you are a beginner, most resources are mostly the same. Just choose one, whatever it might be, and stick with it. It will give you direction and purpose. Googling "best online coding course for beginners", jumping from one resource to another, and looking for that perfect tutorial is a waste of time. You could have just done another chapter! :)

-  Learn to read documentation. Yes, it is a giant pain, it is very confusing, and I am absolutely terrible at it. But documentation is the absolutely first place I look. Googling and looking through stackoverflow is my last resource. The more I work with documentation, the faster I find answers, the easier it is for me to understand what I am looking at, and how to apply what I see.

 - It is not easy to say, but I am a pretty lazy person by nature. It helps to find a system that keeps you focused and engaged. For me, I discovered a Pomodoro Technique. You can follow the link to learn about it, if you have never heard of it, but in a nutshell you study in 25 minute bursts, and then break for 5 minutes. It really works for me, and it completely changed the way I study. I don't get distracted, I am very focused and very productive. You don't have to use the Pomodoro Technique, but finding a system that works for you will increase your productivity.

- Set small daily and weekly goals. It gives purpose, and makes you excited to sit down and work on stuff. For example, my weekly goal might be "Complete Chapter X". But the goal for the day might be "Finish specific script or part of the script that I am working on" or "Learn about a specific topic".

- Get involved. Codenewbie.org is an amazing resource for those who are learning code. Getting involved, participating on the forum and in their twitter chat will accelerate your learning and will give you needed encouragement when you might be struggling. Find local Meetups in your area, and go to them. You WILL learn faster, and you might find a coding buddy, a mentor, and maybe even a future employer. Oh, and if you don't have it yet, get a twitter account ;)

- Don't code or study when tired. You will not retain information well, it is difficult to focus, and it is a waste of time. Just go to bed, get some sleep, and start fresh in the morning.

- Code. Every. Day! It really helps to get settled into a habit, and it also means that every day you are making progress!

 My plans for the next week are:

 I am attending a Ruby meetup in Baltimore on Tuesday, so I am really looking forward to that. I plan on finishing Chapters 46 and 47 of Learn Ruby the Hard Way, and finish Chapter 2 of Hartl's Rail's Tutorial.

That is all for now,

I hope you found this post useful, and as always, thank you very much for reading!

Keep Calm And Code On,

- Andrei




Friday, October 9, 2015

Rails Hartl Tutorial and end of the week update

  Hello, everyone!

  Another week is almost over, and in two days I will have already been "learning code" for two months. Time flies when you are having fun, I guess :)

  Me and two other #codenewbie slack members (twitter handles: @Jonai_Live and @RandyTorres23) started a small study group, and we will be going through Hartl Rails Tutorial together. We are planning on doing a weekly Hangout on Sundays to discuss the week's material, help each other through issues, and decide on the goal for the following week. Chapter 1 is the goal this week. It is a short chapter that mostly deals with setup. It has you setup rails, git and heroku. As an assignment for the chapter, a small rails app is developed and launched live to the web using heroku. Here is mine (don't get excited, it is not much at all): Chapter 1 app .   I am done with Chapter 1, and looking forward to the Sunday Hangout.

  In other plans, I am attending two more Ruby meetups: one tomorrow in Washington DC (the same one I went to two weeks ago), and one in Baltimore on Tuesday. I will definitely let you know how that goes.

  I am still working on Zed Shaw's "Learn Ruby the Hard Way", even though it has been kind of an a back burner this week. The goal is to finish the book completely along side with couple of other things I am working on.

  This week I have started on working on a script of my own as a side project. Not much to say right now, I am still trying to narrow down what I want it to do (and how). As this project develops, I will be covering it more in this blog.

  In the next blog post, I will attempt to do a summary of my two months learning code, with some tips for anyone who is about to (or thinking about) starting this journey :)

  That is all for now!

  I will talk to all of you cool people later,

  -Andrei

 PS. On an unrelated note, I had a chance to see "Martian" yesterday. What an awesome movie! Definitely recommend! :)




  

Tuesday, October 6, 2015

Codenewbie.org and Ruby Monday

  Hello, everyone!

  I have been a lurker in the codenewbie community for about a month now. It is a very active community designed to help new developers. They have an active forum, webpage with lots of articles. They host a weekly twitter chat for beginners etc.

  They also have a Ruby Monday event where they host a Google Hangout and collaborate on a project. I joined them last night to listen in. I must say pretty much everything just went above my head. I understood on the high level what was discussed, but I did not understand specific code. But it was still a good experience, and I am glad I participated. Listening for two hours to several people discussing code exposed me some more to the process of team coding, jargon and code logic.

  I also met a couple of other new developers, and we are thinking about forming a study group, and work through a tutorial or a specific book together.

  I highly recommend checking out and participating in the codenewbie community if you are a new developer.

  - Andrei

Sunday, October 4, 2015

Shopping made easy (Ruby Edition)

  Hello, everyone!

  Chapter 45 assignment is done. My game is ready, and the code is 100% complete. I have to finish writing out flavor text, and I will do it in my spare time over next couple of days.

  The only thing I had left to do today was finish code for the shop where Hero can spend gold to buy gear, and man, that proved to be the most difficult part of the game! I never expected it. I thought coding the combat sequence was tough.

  So the idea behind the shop, that it will have items for sale where the Hero can spend gold to buy items that will boost his stats. (like a better shield will increase Armor, better sword would increase Attack, etc). I had the following items that I wanted to have available in the shop.
  1. Magic Hammer: increases Attack Range for the Hero (8 gold)
  2. Magic Sword: Increases Attack Range, Hit Chance and Crit Chance (10 gold): slight boost to many stats
  3. Magic Shield: Increases Armor Class (7 gold)
  4. Magic Boots: Increases Hit Chance  (5 gold)
  5. Magic Ring: Increases Crit Chance (5 gold)"
  6. Health Potions: Increases Health Potion Count by 1 (1 gold) - no stat boost, but increases gives 1 more potion.

At first I had it written out in a hash with the name and cost:




  That works fine for asking what item you want to buy, and deducting the cost from the total hero's gold. But the problem was that I had to increase the appropriate stats depending on what item was purchased. I could do it with a bunch of "if .. else" blocks, but that is so ugly, plus what if I had 1000 items that hero could choose from?

  I finally realized that the values for the keys in my hash could be ARRAYS! So I needed a new array that would take starting values of all the stats of the hero. I called it @stats. The array in the key value pair in the @shop hash will hold the modifiers for those stats plus an extra element that would hold a string with the name of the item. When an item is purchased, the elements in the same index of both arrays are added together to get updated stats for the Hero. I had to write a method that would "add" elements of both arrays together, which I called "upgrade".

The only other thing I had to do was, change the gold cost value to negative, so it subtracts.










  Once I got over that hurdle, it was a lot easier to finish out this code. I had to add a check before every single purchase to verify that the Hero can afford the item he/she is requesting, with a message if the item is too expensive.

  I also had to make a separate code for purchasing a potion, because all it would do is increase the number of potions the Hero has by 1.

  Final thing is to update all the Hero Stats to values of elements in the @stats array after the shopping is done.

Final code for the Shop looks like this: 



You can see the full code on Github if you prefer it that way here.

 This was a fun challenge to overcome for me, and I feel like I learned a lot. Trying to complicate the game just created additional puzzles that I had to figure out.

  I will start Chapter 46 in Zed Shaw's "Learn Ruby the Hard Way" tomorrow!

  Thanks for reading!

 - Andrei




Saturday, October 3, 2015

Chapter 45

  Hello, everyone!

  Just a quick update here,

  Still working away on Zed Shaw's "Learn Ruby the Hard Way" Chapter 45. In this Chapter, the goal is to make a game using classes and modules. Mr Shaw encourages to make this game as complex as you can, and I am really taking it to heart. I gave myself about a week to work on it, and today is Day 8, so I am running a little behind my schedule, but the good news is that the actual code is mostly done. I was going to just go to the next Chapter, but my wife now wants to play the game I made, so I will spend a little bit of time to fill out the "flavor text" in the game, and balance it to make it easier to win.

  At first, I was going to make a simple dungeon crawl game, where you go through the dungeon, fighting monsters until you get to the boss in the end, who you have to defeat to win. It started out simple, where the hero and monster would just have a couple stats (such as HP, Attack Strength Range, and Armor Class).

  Now, after a week of going over the code and adding new features, the Hero of the game will have the following stats:
  - HP: total hit points
  - AC: Armor Class (the monster has to roll higher than AC on a 20sided die to not get blocked)
  - Attack_Range:  the range for the damage Hero deals on a successful hit, will be improved with better weapons and/or spells
  - Crit_Chance: a chance that the damage that the Hero deals will be doubled
 - Hit_Chance: a modifier that will help the Hero to avoid being blocked by a monster
 - Wisdom: this will improve the strength of the Hero's Spells and will help detect traps
 - Gold: as Hero defeats monsters, he also collects gold that can be spent on better gear and health potions.

  Hero can cast spells during combat that will do damage, or increase his stats for the duration of the combat. Hero can also find a bow during the game, and will be able to deal ranged damage before actual combat begins.

  Also when the game starts, a player has to choose a specialization for a Hero: Strength, Dexterity or Wisdom. Depending on the Choice, certain stats will be increased for the newly created Hero.
For example, Strength will increase HP, AC and Attack Strength.

  This is what my Hero Class looks like now:




Passing 6 parameters in a little much, but I figured that I am only creating one instance of this class, so it might be ok in this case.







Here is what my Monster Class looks like:


Many instances of the class Monster will be created during the game, so there are only two parameters, with the second one being a hash "options", that will hold all of the monsters stats. If the hash does not contain a specific stat, the default values for the stat will be used.






All in all, I am pretty excited to get this game finished, and move to the next Chapters. Tomorrow, my goal is to have all the code 100% complete and working, so that I can start next Chapter. I might have some flavor text left to fill out, and work on fight balancing, but I can do that in my spare time from coding.

Have a great day everyone, and thanks for reading my blog!

-Andrei