Sunday, April 29, 2012

Code Academy Week 3

Another week has passed.  Has it really been 3 weeks already?  This week continued with us building apps using rails.  The important thing we learned this week was building apps that pull data from a model (database).  I learned how to submit form data that can add or update information in my model.  I also can delete info from the model.  I immediately used these new skills to rebuild the Reading Glue library app.  I can view a summary list of all titles in the library.  The information is all dynamic and will automatically update as the database changes.  I can click a title and view all relevant information about that book title.  As with the library summary list, this information is all dynamic.  I added functionality to allow an admin to add a new book, update the details about a book, or delete a book if needed.  In the next day or two, I plan to start adding some search tools to the library.

I am looking forward to what I am sure is going to be taught to us this week in regards to relating models to each other.  This will be helpful so I can start building the functionality to allow a user to add a specific title to their account.

Overall I feel like I am keeping pace.  I don't have a lot of the commands memorized yet.  I am sure that will happen over time as I type them over and over.  I still find myself looking back at my notes for specific command details, but I feel pretty confident in my knowledge and understanding on the general structure of a rails app.  Although I feel pretty comfortable understanding how the routes work, I do have some questions as it relates to paths.  My mentor introduced me this week to using the actual path to link to different pages in my app rather than using the http address.  This is pretty straight forward for general pages, but when you start using params data in the path, then I am getting a bit confused.  I know this is a bit ahead of where we are in class, so maybe my teach Jeff is able to break it down for us where I can understand it a little better.  I would have never thought that in three weeks I would have the skill set to build this much.  Not only do I have the skill set to build these tools, but my mindset and thinking patterns are starting to change.  I seem to have programming and code on my mind 24/7.  It certainly is not a bad thing.

Time management of everything is still hit or miss.  It is really hard juggling class, study time outside of class, a full time job, and being a full time father / husband.  It is only going to get harder in the coming weeks, so I know I am going to need to make some adjustments to allow everything to work without one obligation going up in flames.  So far my family has been awesome during this experience.  Julie is usually the one who gets shafted out of spending time with me.  I have a lot of making up to do on Mothers Day and after this class is over.

Sunday, April 22, 2012

Code Academy Week 2

Week two is officially in the books, and so far I am feeling pretty good.  We started off the week making sure everyone had a good understanding of arrays and hashes.  We also learned how to create a new Class and call methods inside those classes.  I felt confident that I knew exactly everything that was going on four hours into class on Tuesday.  Then the final hour of class came around, and I felt my head was going to explode.

Our TA, Raghu, gave us a challenge of calculating the same shopping cart exercise we were assigned as homework last week, only this time were were to convert it into a program that used classes and methods to make the calculations / print the total.  Usually we pair program, but on this day I was flying solo.  It felt like the entire class was marching forward, while I just sat there trying to think through where to even begin.  I started laying out my thoughts, and deleted them.  I then started again, and once again felt like I was heading down a dead end road.  After about 10 minutes, I asked for a little help on how to get started.  Come to find out, I was originally headed down the correct path.  Raghu reviewed the solution with the class very quickly.  I had no time to copy the solution down, but I felt like I understood the general thought process and how he came up with his solution.

After class, I tried to work on the same problem from scratch.  I was totally stumped, and could not get the program to return the shopping cart total value correctly.  I must have sat there for about an hour and half trying to figure it out before I decided to take a break and head home.  That night I took another stab at it.  I sat there for a couple more hours puzzled why my solution was not working correctly.  My code looked like:

  def total
    total = 0
    @cart_array.each do |i|
      total += i[:item].cost * i[:quantity]

Everything seemed to be correct.  I was pulling out the item, applying the cost to that item, pulling out the quantity from my array.  I then multiply them, and add that calculation to my running total.  I wasn't getting any errors, but I also was not getting the total cost for my shopping cart.  What could be wrong?  What I realized after staring at my screen for 3+ hours is that my method was not returning anything, because I had not told it to return anything.  Just because I was running the calculation did not mean that the method automatically is going to return that info.  Once I added the "return total" to my method, everything worked.

  def total
    total = 0
    @cart_array.each do |i|
      total += i[:item].cost * i[:quantity]
    return total

We also learned how to output data automatically into a html and css file.  It finally seemed like we were doing something real.  Something that I could easily apply to the app I want to build.  I spent that night and next day building a program that would add book titles, author, and reading level into a library.  The program then would output a summary of all books in that library.  This exercise helped me  make sure that I truly understood methods, and how they return information when called.

Thursday was exciting because we jumped into Rails for the first time.  We built a basic web app that had an index page with an ordered list of landmarks.  When clicking on the landmark, you would go to a details page that was dynamically put together by the ruby code embedded in the *.html file.  Once again, I went home and built a version of this same app that related to listing books in a library.  It had dynamic detail pages for each book that would list important information about the book that was clicked.  I really feel like all of this is coming together.

On Friday, I went to Eight Bit Studios to meet with my mentor Don Bora.  We went over the library app I had made the night before, and he introduced me to the "before_filter."  Basically this can be added in your controller file.  You can add a method that will then be used in all of your pages without repeating the code each time.  Don and I spent some time discussing my app, and where I should begin.  Basically I mapped out everything I want to build in the next 10 weeks.  I broke this up into the main sections such as user accounts, library, and backpack.  Under each of those sections I have a list of the the functions and sub-functions that will need to be built.  I am going to try and bite off a piece each week with what I learn in class.  I am really excited to get going on this.

Sunday, April 15, 2012

Code Academy Week 1

Back to blogging on a weekly basis.  I tried to keep up with it before, but kind of came to a point where I was too busy to sit down and type my thoughts out.  Neil, Mike, and the other members of the Code Academy team encourage weekly blogging.  I am going to be totally honest and share what I find to have been easy, hard, and even stupid mistakes.  I know sometimes I am afraid to admit stupid mistakes, especially when it seems I am the only one that is making them.  It is also hard sometimes to reach out for help when you feel the area you struggle with is something that everyone else has mastered already.  By sharing these experiences on my blog, I hope it encourages others to feel free to admit when they need help.

Week 1 went by in a flash.  Only ten more weeks until demo day.  This week was pretty laid back.  Tuesday was consumed with introductions, general info, and some playing around with html and css.  We also created our first ever ruby file.  Thursday ramped up a bit.  We started learning more about some of the ruby methods and how to create our own methods.  We were also introduced to lists and how to create and extract data from an array or hash.  I can see that we will be building upon concepts pretty quickly.  I am trying to create a habit of immediately after class trying out all the examples we worked on in class to see if I can complete them by memory.  I was actually surprised at how much I had to revert back to notes when going through these problems only 1 hour after class ended.  This is a pretty good indication that I need to practice more, so that is what I did this weekend.  We were assigned a simple shopping cart exercise to work on over the weekend, and I decided to sit down last night and take a stab at it.  I was able to get about 90% of it completed on my own.  I struggled to complete the last part of the exercise which was make the code change the quantity of one of the items in my shopping cart.  I knew exactly what to do, but I kept getting an error.  After trying to figure out what was going on for nearly an hour, I cracked and took a peek at the answer.  I had typed the following statement:

shopping_cart[1[:quantity]] = 3
print_total(shopping_cart, sales_tax, params)
My mistake was that I thought ":quantity" needed to be included within the array item number's "[ ]".  After looking at the correct solution, I found out that it should look like:

shopping_cart[1][:quantity] = 3
print_total(shopping_cart, sales_tax, params)
I guess this is my first taste of pulling my hair out for an hour.  I was trying to debug something that is such an obvious oversight to me after the fact.  I guess that is all part of the learning process.

Another interesting thing that happened this week was that I met my mentor Don Bora.  I think this was the most exciting part of my week.   Don is one of three owners of Eight Bit Studios in Chicago.  Come to find out, Don has a passion for transforming education in the same way that I do.  He has worked on many projects in the past that are focused on education.  I think this is going to be an awesome fit for me as I look to build Reading Glue during the next 3 months.  I am not sure if this pairing was intentional or not.  If it was intentional, then bravo to Dave Hoover or whoever put this pairing together.

Today I am working on Chapter 2 of the Hartl Ruby on Rails Tutorial and also chapter 7 of Learn to Program by Chris Pine.  It is only one week and I know a lot more then what I ever had before.  I am so pumped about the exciting atmosphere of Code Academy.  My classmates are all very inspiring.  I said it before, and I will say it again.  This quarter we are going to see some magic happen in Chicago.