Wednesday, May 13, 2015

Day 112: Coding Module, Intro to Ruby, Hackerspace Meetup, and LinkedIn

O.k., I'm finally on Module 4, "Web Markup and Coding."  Now, I've already spent quite a bit of time coding up web pages using HTML and CSS on Treehouse and on The Odin Project, so I have a solid grasp of HTML and CSS.  Because of this, and because I received the email recently from the Viking Code School letting me know time is of the essence, I'm skipping the HTML and CSS part of the module for now and focusing 100% on Ruby.

So, now that I understand what the prep work is really about, here's the plan for passing that test:

1.  Skip the HTML and CSS sections of Module 4 for now.  I already know HTML and CSS, and completing the HTML and CSS work in the module now would take away valuable time from me, time which I need to invest in learning Ruby.
2.  Start on Chapter 11, "What is Ruby," and blaze through the module, thinking, eating, and breathing Ruby.
3.  Take the test once I have solved Euler Problems 1 through 4 in Ruby, as well as completed the project at the end of the module.
4.  Stay focused, and put in 12 hours a day until this is done.

That's the plan.

O.k., I started with Chapter 11, "What is Ruby?"  The chapter was a brief introduction to Ruby and Ruby on Rails.  Next was Chapter 12, "From Pseudocode to Ruby."  The instructor ended up translating this pseudocode:




To this actual Ruby code:




That's neat.  I copied and pasted the Ruby code into the terminal on my mac and then entered deaf_grandma into the terminal to run the program.  It worked!

Next was Chapter 13, "A Taste of Ruby."  For that chapter, I went over some exercises at tryruby.org.  In one of the exercises, we used the .reverse method, so for example:

"Jimmy".reverse

Would output:

"yimmiJ"

That's awesome, because I know that Euler Problem 4 has to do with palindromes, so that will help me solve that one.  For a number, we can do:

40.to_s.reverse

Which will return "04".  "40".reverse will also return "04".  These methods allow us to convert values to other types of values"

to_s converts values to strings
to_i converts values to integers
to_a converts values to arrays

.max right after an array will return the highest number in the array.
.sort right after an array will return a copy of the original array, sorted from lowest number to highest number, in order, but will leave the original array alone.
.sort! right after an array will modify and return the original array, sorted from lowest number to highest number, in order.

An exclamation point at the end of a method means to impact the current data, instead of making a copy.  So, if there is no exclamation mark, the output is a copy, if there is an exclamation mark, the original data is actually being modified.

poem.include? "something"

The code above will tell you if the poem includes the "something" string.  Here's a list of the complete list of methods for stings:

http://ruby-doc.org/core-2.2.2/String.html

Hashes are used to pair up a key and a value, they are not used for keeping things in order.  For example:




The hash was created in the first line.  The lines after that entered keys into the hash and gave them values. The link below goes into hashes in depth:

http://ruby-doc.org/core-2.2.2/Hash.html

I attended a Hispanic Hackers Meetup today at Hackerspace.  It was fun, I learned about ways to optimize a LinkedIn profile (I didn't even have one, so I created a LinkedIn account) and met other Hispanic web developers, including one who used to work as a journalist, went to a coding school, and has now landed a web developer position.  I also learned a little more about Capital Factory, a startup incubator space here in Austin, TX.  

All in all, it was a great day.

SUMMARY OF CODING SKILLS

Total Treehouse Points: 5,385

Treehouse Points by Subject Matter (Miscellaneous not included): 
HTML:                                663 
CSS:                                1,599 
Design:                            1,193 
Development Tools:            747 
Javascript:                      1,120

Treehouse Ranking (%): "You have more total points than 94% of all students."

Treehouse Badge(s) Earned Today:



Treehouse Courses Completed:
How to Make a Website
HTML
CSS Foundations
CSS Layout Techniques
Aesthetic Foundations
Design Foundations
Adobe Photoshop Foundations
Adobe Illustrator Foundations (66% complete, switched focus from web design to web dev)
Git Basics
Introduction to Programming
Javascript Basics

Codecademy (& other) Courses Completed:
HTML and CSS (Codecademy) 

Books Read or in Progress:

Completed: "Head First HTML and CSS," by E. Robson & E. Freeman
In Progress: "Eloquent JavaScript," by Marijn Haverbeke (On pg 27)
In Progress: "Head First Javascript," by Eric Freeman and Elisabeth Robson (On pg 56)
In Progress: "A Smarter Way to Learn Javascript," by Mark Myers (on pg 72)

My Progress on The Odin Project:
1.  Introduction to Web Development             100% Complete
2.  Web Development 101                                29% Complete
3.  Ruby Programming                                       0% Complete
4.  Ruby on Rails                                               0% Complete
5.  HTML5 and CSS3                                           0% Complete
6.  Javascript and JQuery                                  0% Complete
7.  Getting Hired as a Web Developer                 0% Complete

Hours Spent Coding Today: 7
Total Hours Coding: 545

Monday, May 11, 2015

Day 111: Engineering Module

O.k., back at it, I started the day by reading a long blog post by a google employee about SOA, then watched the SOA video I watched yesterday again.  Now, moving on to Chapter 20, "Characteristics of Good Systems." 

After reading that chapter, which went over the ideal characteristics of modular systems, I moved on to Chapter 21, "SOLID Design principles."  This is great, i'm one chapter away now from the module project, and once I'm done with that, there will only be one more module left before I take the test.

Here's the components of the SOLID acronym:




Finished that chapter, now I'm moving on to Chapter 22, "Pseudocoding Modular Design."  I'm so close to completing the module!

O.k., so for chapter 22, our assignment is to write up an elevator program by working with pseudocode, with a focus on breaking code into modules.  

I ended up working on the elevator problem for about 9 hours on and off over the past week and came up with many different versions, but none of them were really fully functional, due to the problem of setting up some kind of queue to hold floor pick-up requests and floor drop-off requests.  Here are my notes, I did so much more, but ended up deleting and rewriting code many, many times:

PROGRAM Elevator:
    IF (up or down call button is pressed)
        IF (elevator is stopped on that floor)
            THEN OpenElevatorDoor;
            THEN DestinationFloor;
        IF (elevator is not stopped on that floor)
        THEN go full speed to that floor, and SlowDownIfNecessary
            IF (elevator is moving OR stopped between floors) 
                THEN do not open elevator door;
            END
        THEN OpenElevatorDoor;
        THEN DestinationFloor;
    ELSE stay in idle mode;
END

PROGRAM SlowDownIfNecessary:
    IF (we are traveling up at full speed)
        IF (we are only 1 floor away from the lowest destination floor OR there is a pending destination floor in the destination floor queue one floor away or more that has been pressed between the current floor and the destination floor going in the same direction the elevator is going)
            THEN slow down;
        END
    ELSE IF (we are traveling down at full speed)
        IF (we are only 1 floor away from the highest destination floor OR there is a call button 1 floor away or more that has been pressed between the current floor and the destination floor going in the same direction the elevator is going)
            THEN slow down;
        END
    END
END

PROGRAM OpenElevatorDoor:
    IF (the elevator is stopped at the destination floor OR stopped at a floor on the way to the destination floor)
        THEN open elevator door;
        THEN wait 30 seconds;
    While (there is a human in the door closing path)
        THEN open elevator door;
    THEN close elevator door;

PROGRAM DestinationFloor:
    READ destination floor in queue;
    IF (user selects a destination floor that is higher than the current floor)
        THEN go up full speed to that floor and SlowDownIfNecessary
            IF (elevator is moving OR stopped between floors) 
                THEN do not open elevator door;
            ELSE IF (elevator is currently stopped at the destination floor)
                THEN OpenElevatorDoor;
    ELSE IF (user selects a destination floor that is lower than the current floor)
        THEN go down full speed to that floor and SlowDownIfNecessary;
            IF (elevator is moving OR stopped between floors) 
                THEN do not open elevator door;
            ELSE IF (elevator is currently stopped at the destination floor)
                THEN OpenElevatorDoor;
    ELSE (OpenElevatorDoor)
END

PROGRAM FloorQueue (very rough draft)
IF (a up or down call button is pressed OR a floor button inside the elevator is pressed)
    THEN add a destination floor in a queue corresponding to the button pressed;
WHILE (there are destination floors in the queue)
    THEN keep going until there are no destination floors left in the queue;
IF (the elevator stops at a floor)
    THEN remove any matching destination floor(s) from the queue;

I could keep working on the elevator problem, and then work on the project for the module, but the thing is, I received an email from the Viking Code School yesterday letting me know that my application will be deleted if I don't let them know that I am still working on things.  So, I let them know to keep my application active, because I am still working on the pre work, but in order to get to actual Ruby code as soon as possible, which I need to know in order to take the exam, I'm moving on ahead to the next module.  
I did get a ton of practice pseudocoding, though, because I worked on that elevator problem for what seemed like forever.  The notes I posted are just a small part of all the variations I went through while working on it, so I did find this chapter extremely helpful, even if I am not posting a fully functional elevator.  That said, posting a fully functional elevator wasn't actually the assignment (there are entire books on this), but rather, the assignment was to work with breaking code up into modules, and that I did many times as I went through different iterations of my attempt at an elevator program.  

O.k., I read through chapters 23, 24, 25, AND 26, and now I'm moving on to the final module.  I'm thinking once I learn Ruby I'll come back to the elevator problem and try it again, armed with more coding concepts!  :)

SUMMARY OF CODING SKILLS

Total Treehouse Points: 5,385

Treehouse Points by Subject Matter (Miscellaneous not included): 
HTML:                                663 
CSS:                                1,599 
Design:                            1,193 
Development Tools:            747 
Javascript:                      1,120

Treehouse Ranking (%): "You have more total points than 94% of all students."

Treehouse Badge(s) Earned Today:



Treehouse Courses Completed:
How to Make a Website
HTML
CSS Foundations
CSS Layout Techniques
Aesthetic Foundations
Design Foundations
Adobe Photoshop Foundations
Adobe Illustrator Foundations (66% complete, switched focus from web design to web dev)
Git Basics
Introduction to Programming
Javascript Basics

Codecademy (& other) Courses Completed:
HTML and CSS (Codecademy) 

Books Read or in Progress:

Completed: "Head First HTML and CSS," by E. Robson & E. Freeman
In Progress: "Eloquent JavaScript," by Marijn Haverbeke (On pg 27)
In Progress: "Head First Javascript," by Eric Freeman and Elisabeth Robson (On pg 56)
In Progress: "A Smarter Way to Learn Javascript," by Mark Myers (on pg 72)

My Progress on The Odin Project:
1.  Introduction to Web Development             100% Complete
2.  Web Development 101                                29% Complete
3.  Ruby Programming                                       0% Complete
4.  Ruby on Rails                                               0% Complete
5.  HTML5 and CSS3                                           0% Complete
6.  Javascript and JQuery                                  0% Complete
7.  Getting Hired as a Web Developer                 0% Complete

Hours Spent Coding Over the Past Week:1 1
Total Hours Coding: 538

Sunday, May 3, 2015

Day 110: Engineering Module Chapter 15, "What is Pseudocode?"

All right, I should start this entry tomorrow, but it's 1:03 a.m. and I feel like continuing with my studying, I'm rehydrated, refreshed, and ready to go.  :)

I'm starting with Chapter 15, "What is Pseudocode?"  I'm pretty stoked to learn about working with pseudocode.  I understand the basics of pseudocode now, and I watched a Khan Academy video on pseudocode.  Here's a great example of pseudocode from the chapter!



In the video, the author actually wrote the pseudocode into the text editor, which is something the chapter mentioned we could do, but I've never done it myself.  I like it.

Next, I started on Chapter 16, "The Elements of Pseudocode."  The chapter started off by stating that we will start referring to our pseudocode as either a "program" or a "script" (or later, a "module").  The chapter mentioned that programs run from top to bottom, which I had learned previously while working with html/css/javascript.  Here's a pseudocode example from this chapter:


Then here's the same, but with syntax a bit more formal (closer to actual code):



Neat.  And then here's a while loop:



I've used loops before, so I'm familiar with a while loop.  Then here's one that's new to me, "TIMES DO," which when preceded by a number, will repeat the code following it as many times as the value of the number.



Then we have this one, "EACH," which is totally new to me:



I want to work with that one more to get some practice with it.  So, to sum up, we went over IF, ELSE, IF ELSE, DO, WHILE, EACH, "X" TIMES DO, and WHEN.

I went through a slide presentation on pseudocode with 164 slides, and then I decided to practice by making my own pseudocode for the Floyd Mayweather - Manny Pacquiao fight, just for fun, and to start flexing my pseudocode muscles.  Here it is, from Mayweather's perspective (FM is Floyd Mayweather and MP is Manny Pacquiao):

PROGRAM DefeatMannyPacquiao
     WHILE (MP is still standing) DO
          IF (MP jabs) THEN
               FM take a step back and throw a jab
          ELSE IF (MP throws an uppercut) THEN
               FM take a step back and throw a jab
          ELSE IF (MP throws a haymaker) THEN
               FM take a step back and throw a jab
          ELSE IF (MP takes a step back) THEN
               FM take a step back and throw a jab
          ELSE 
               FM take a step back and throw a jab
     END
END

Just having some fun with things before I go to bed. :)

O.k., I'm awake now, and I'm going to continue the same blog post, since the earlier content from this post was made in about an hour of work very late last night.  Ideally, I can complete up to chapter 22 today and then do the module project and the three "wrap-up" chapters tomorrow.  Getting all of that done is a fair amount of work, so let's get going!

Here's how to make a cup of tea in pseudocode (you can remove the PROGRAM and END part if you want to keep it less formal):



This pseudocode is to check if a number is bigger than another:



I learned that iteration is another word for loop.  Here's an example of a while loop in pseudocode:



This is the format for the pseudocode above:




I like practicing with pseudocode, it helps me think like a programmer.  This code prints out the numbers 1 through 5:




Neat.  Here's some pseudocode to look through a phone book!




This is fantastic, I'm really enjoying this.  I can see how you can start with these building blocks and build greater things.  Here's a complete pseudocode program for making that cup of tea:




I like this.  Let's do some more examples, below, let's say we want to "Read in a number and print it out."




Next, below, let's say we want to "Read in a number and print it out double the number."




Next, below, let's say we want to "Read in a number, then check if it is odd or even."




Next, below, let's say we want to "Read in two numbers, call them A and B.  If A is bigger than B, print out A, otherwise, print out B."




Some more!  This is great, I like getting in all these examples, I'm going to be re-writing them on my dry erase board!  Next, it gets a little more complicated, here's the goal:



And then here's the pseudocode below:




Ok.  Then let's say, below, we want to "Print out the numbers from one to 5."



Or, below, if we want to "Add up the numbers from 1 to 5 and print out the results."



Next, below, is this one, "Read in a number and check if it's a prime number."  As an additional explanation, a prime number is a number that is only divisible by itself and 1, for example, 7 is a prime number.  From the slide:

Another way to put it is that every number other than itself and 1 gives a remainder, for example, for 7, if 6, 5, 4, 3, and 2 give a remainder, then 7 is prime.  So, all we need to do is divide 7 by all numbers less than it, but greater than one, and if any of them have no remainder, then we know it's not a prime.

Now, before I post this one, the code that follows will help me solve that third Euler problem I was stuck on a while back, so that's pretty awesome...


And then here's the code below...this is great...I'll have to go over this again several times until I can write it from memory, it will help me solve Euler Problem 3.



O.k., I'll have to save that and work on it when I get into the coding module, because I don't want to get sidetracked, I want to move on to the next chapter, so, moving on to Chapter 17, "Practice with Pseudo-coding."

For chapter 17, the first assignment is to write the instructions for making a grilled cheese sandwich in pseudocode (it should be at least 20-30 steps).  Here's my work:

PROGRAM MakeGrilledCheeseSandwich:
     Retrieve a tomato from the refridgerator;
     Retrieve a jalapeno from the refridgerator;
     Retrieve an onion from the refridgerator;
     Retrieve a bottle of mustard from the refridgerator;
     Retrieve a bottle of mayonnaise from the refridgerator;
     Retrieve a loaf of bread from the pantry;
     Retrieve a cutting board from a kitchen cabinet;
     Retrieve a blade from a kitchen drawer;
     Organize all the above items on the kitchen island;
     Cut two big slices off of the tomato;
     Cut a small slice off of the onion;
     Cut the jalapeno into small pieces;
     Take two slices of bread and lay them on a plate next to each other;
     Put mustard on what will be the bottom slice of bread;
     Put mayonnaise on what will be the top slice of bread;
     Put two slices of cheese on what will be the bottom slice of bread;
     Put the jalapeno pieces on top of the cheese;
     Put the tomato slices on top of the cheese;
     Put the onion slices on top of the cheese;
     Put the top slice of bread on top of the slice with most of the ingredients on it, with              the mayonnaise side facing down;
     Plug in your George Foreman grill;
     Place the grilled cheese sandwich in the grill;
     Grill for two minutes or until bread crisps and cheese melts;
     Turn off George Foreman Grill;
     Eat sandwich;
END

The next assignment is to write a program which will acquire a variable number of items from a grocery store with 10 unlabeled aisles, and which will then check out with all the items (it should be more than 50 steps). 

So, I went with a WHILE loop for this one instead of doing 50 plus lines, like so:


PROGRAM Shopping:
     READ list of items;
     DO grab a shopping cart;
     DO walk through the aisles, from the first to the tenth, viewing every item;
     WHILE (item that you are looking at does not equal any of the items in the list AND                there are still items in the list)
          DO keep walking down the aisle looking at items;
          IF (item you are looking at matches an item on the list)
               DO remove the item from the list;
               DO place item in your shopping cart; 
          ELSE IF (there are no more items in the list)
               DO take shopping cart to checkout counter;
               DO pay for items in shopping cart;
          ELSE IF (item in list of items has not been found after searching entire store)
               DO remove item from the list;
               DO take shopping cart to checkout counter;
               DO pay for items in shopping cart;
     ENDWHILE
END

It took me 18 lines, and I could have taken many more lines and not used a WHILE loop, but I was a bit out of practice with loops, so I thought it would be good for me to work on a loop.

The next assignment involves a logic game with these rules: 



And this is the pseudocode I came up with:


PROGRAM LogicGame:
NumberWeAreOn = 1;
PersonWeAreOn = 1;

WHILE (NumberWeAreOn <= 100) 
     NumberWeAreOn = NumberWeAreOn + 1;
     PersonWeAreOn advances one person in the current direction (begin by going                          clockwise around the table);
     IF (NumberWeAreOn / 7 = No Remainder)
          DO PersonWeAreOn advances in the opposite of the current direction;
     ELSE IF (NumberWeAreOn / 11 = No Remainder)
          DO PersonWeAreOn advances two people instead of one;
     ELSE IF (NumberWeAreOn = 100)
          THEN print PersonWeAreOn;
END

I really want to be able to solve that problem now using actual code.  I'm curious as to how the "switch direction" feature would be handled.  So, I'm done with that chapter, and now I'm moving on to Chapter 18, "Solve Complex Problems Modularly."

We discussed modularity, which is the degree to which a system can be broken into its components.  The best solution to our design challenge isn't one giant task but a system of separate and mostly independent sub-tasks working together towards a common goal.  Viewed another way, modularity is separating and delegating. Wikipedia defines modularity as the degree to which a system's components may be separated and recombined.  

Next was Chapter 18, "Amazon.com: A Modularity Case Study."  The term Service Oriented Architecture (SOA) was introduced, which is a high level architectural pattern used by many top software companies today which basically embodies the idea of modularity on a large scale.  In SOA, each separate sub-section of the overall architecture is designed to be completely independent from every other and they communicate using specified interfaces (called Application programming Interfaces (API's)).

I saw a video about SOA, which mentioned that SOA does affect performance (slows it somewhat), but at the same time, makes a system easier to fix when it breaks, due to the modularity.  I read an interesting email by Jeff Bezos.  

O.k., it's late, time to call it a night, I'll pick up on Chapter 20, "Characteristics of Good Systems" tomorrow.

SUMMARY OF CODING SKILLS

Total Treehouse Points: 5,385

Treehouse Points by Subject Matter (Miscellaneous not included): 
HTML:                                663 
CSS:                                1,599 
Design:                            1,193 
Development Tools:            747 
Javascript:                      1,120

Treehouse Ranking (%): "You have more total points than 94% of all students."

Treehouse Badge(s) Earned Today:



Treehouse Courses Completed:
How to Make a Website
HTML
CSS Foundations
CSS Layout Techniques
Aesthetic Foundations
Design Foundations
Adobe Photoshop Foundations
Adobe Illustrator Foundations (66% complete, switched focus from web design to web dev)
Git Basics
Introduction to Programming
Javascript Basics

Codecademy (& other) Courses Completed:
HTML and CSS (Codecademy) 

Books Read or in Progress:

Completed: "Head First HTML and CSS," by E. Robson & E. Freeman
In Progress: "Eloquent JavaScript," by Marijn Haverbeke (On pg 27)
In Progress: "Head First Javascript," by Eric Freeman and Elisabeth Robson (On pg 56)
In Progress: "A Smarter Way to Learn Javascript," by Mark Myers (on pg 72)

My Progress on The Odin Project:
1.  Introduction to Web Development             100% Complete
2.  Web Development 101                                29% Complete
3.  Ruby Programming                                       0% Complete
4.  Ruby on Rails                                               0% Complete
5.  HTML5 and CSS3                                           0% Complete
6.  Javascript and JQuery                                  0% Complete
7.  Getting Hired as a Web Developer                 0% Complete

Hours Spent Coding Today: 9
Total Hours Coding: 527