Rock, Paper, Scissors, JavaScript

After a busy weekend coding, I managed to get a simple Twitter application working. It’s not anything to look at, but it fulfils the basic functionality requirements, and that’s all that matters for now. Having said that, I’m building up quite a few projects where the functionality has been completed, but the design leaves much to be desired. I better start practising soon since how a site or app looks is incredibly important with regards to how long your potential users want to stick around for.

I paced myself and worked methodically through the task, taking full advantage of the Friday to Sunday time limit. There were a few stumbling points, as is inevitable when completing a task of this nature, but one set of failing tests took me a good few hours to decipher. My first test was to ascertain that previously submitted ‘peeps’ (i.e. tweets), could be viewed on the homepage by anyone who visited it, whether they were logged in or not. Later on, I had to attach a user to peeps, in order to display the username of the person who wrote the peep beside the message. After writing this test and passing it, my first test began to fail. I thought I had broken the code somewhere, but couldn’t find the problem. It was only after going into my database that I discovered the problem. I had fundamentally changed the properties held by instances of the Peep class. They now all had to have a user id, and since the initial test peep didn’t have a user attached to it, that property was coming up as ‘null’, causing the test to fail. When in doubt, check the database.

Today was one of new beginnings: new faces as the November cohort joined us, new seating arrangement for my cohort, new teacher as Enrique passes the baton on to Alex, and new language – JavaScript! All of this novelty was rather too exciting for one packed day at Makers, but of course the focus remained on the coding.

JavaScript is an object-oriented language that can be interpreted by web browsers and is used to add interactivity to web pages. To introduce us to JS, Alex set us the task of coding a simple ‘Rock-paper-scissors’ application, and then making an interactive webpage where a user can play against the computer. Arturo and I managed to come up with something that looked rather decent:

rockpaperscissors

Next step is to apply the same principles to a ‘Rock-paper-scissors-lizard-Spock’ game! Shouldn’t be too tricky, but we’ve got to make sure we get the messages just right: scissors don’t just ‘beat’ lizard, scissors decapitate lizard.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s