Monday, July 21, 2014

I have just began to start my personal project, which will be a web application that users can play chess together.  Currently, the project is a simple registrataion page which uses the HTML's placeholder function in each input to show a water mark of what this input should be filled out with.  Along with this page and the information it passes, the form is also fitted with logic so a user could not simply pass a blank input as there account information.  Also, the username the registrant fills in, is checked against all the usernames currently being used.  If the registrant's username is not unique to the usernames on file, the user will be notified with a message that will explain the situation and to fill in a new username.
The last, and my favorite, part of this program is a feature in the method which checks if the registration form was filled out.  This method is called check_fields(new_user) in the app.rb file, where new_user in a hash which holds all the info the registrant filled in.  This function looks at each input from the registration form linearly to see if the where filled out properly. Here is an example of  the first check of this function, which looks at what the registrant filled in for his or her first name.

24 |  if new_user[:first] == ""
25 |        flash[:registration] = "Please fill in your first name."
26 |        return register_attempt
27 |  end
28 |      register_attempt.merge!(:first_name => new_user[:first])

If the registrant left this field empty (line 24), the user will recieve a message of the problem (line 25), and return a variable called register_attempt (line 26).   This register_attempt variable is the heart of the feature I mentioned earlier.  Everytime the check_fields method is called register_attempt initializes as, register_attempt = {}, an empty hash.  in the case of a feild filled in "correctly" (in away that meets the test's standards), that variable will be saved in the hash register_attempt (line 28).  This enumerable is passed to the HTML page, where it is passed to the inputs value.  This effectivly remembers if your last form had any correct answers, and if it did, this new form would remember and fill those completed fields, so the user is not punished with refilling in the whole form, for one incorrect answer.
As the first week of gSchool comes to an end, I find myself excited, tired, and surrounded by new friends.  Improve was the topic of Monday, and for good reason.  Improvisation is the key to creativity and communication, and besides being uncomfortable really molded a class of strangers into a group of friends in a matter of hours.  The middle of the week was dominated by more traditional exercises.  Using the command terminal, github, and programing as a pair proved somewhat difficult to learn, but with practice comes confidence, and this week ultimately gave the class the foundation all programmers need to be successful.
Today I gave my first lightning talk on the software architecture known as Model-View-Controller, MVC, and with it I made a keynote presentation I was super proud of.  Next week I look forward to learning ruby, and becoming more comfortable with git.