Monday, 21 August 2017

Makers Week Three: Scissors, Paper, Rock!

FLOG IT!



I just finished up my hipster haircut to make me even more "Shoreditch" and while waiting I whipped out my laptop tried to do some coding. Its so cool that you can do this and it makes any queuing that involves the ability to sit a pleasure. I am a Brit after all which means I'm very good at queuing, and this just adds more to that skill.

Shoreditch hipster art stuff and dat

Today we were checking out something for Ruby called Flog. Gem install it and run "flog --g --a [folder you want]" and get your code ranked! We're looking around 15 or less for classes, and under 6 per functions. Newbies should go for 30/10. As you can see my takeaway code did not do so well lol. A big sign of this is that the code is so much bigger in this class then any other.


The main reason we want this is to allow testing to be more efficient, as one change wont be effecting tons of other tests. Its cool to see this represented somehow, its pretty easy to go nuts when making something and not think about good practices.


CODE IS RAMPING UP


Last week went by quickly. Much more complexity was added to our learning as HTML,  and another testing framework called Capybara was thrown in. We learned about the server/client relationship and our week task was to make a web app Pokemon style. 

With complexity ramping up, so does my diagramming!

Unfortunately, I think I was way too casual that week and ended up spending four days setting everything out, then freaking out about not having enough time left. I barely got to the bit where we type in your name.

This freakout was mainly because I had discovered from the students above us that we would be trying to make Rock, Paper, Scissors as a webapp and I knew I hadn't enough knowledge to do this.

The weekend challenge was indeed this, and I had to spend some time looking through the week challenge to work out what to do. In the end, ran out of time. 

Lesson learned. Lets not do that. Especially when we will be getting more things thrown at us at an exponential rate, its really bad to fall behind. Reminds me of missing a few Math AS Level lessons back in the day, when you finally do turn up you are completely lost.

Important to let off some steam with some table tennis madness!


SCISSORS, PAPER, ROCK



Today our coach showed us that she knows her shit by doing our weekend challenge in an hour. It was an amazing sight to see how she worked and how a pro developer builds a program from scratch.



Maybe out of pure boredom and/or genius she threw a curveball at us. This for me highlighted how code can extend problem solving into the realms of thinking out of the box.

So a traditional way of making this game would have the following steps;
  1. Input your name
  2. Input your choice
  3. Make the computer randomly choose. ["Rock", "Paper", "Scissors"].sample. Sample randomly picks from our list here. 
  4. Compare your choice and the computer's and print out the result.
But in true and totally unnecessary form our coach did this;
  1.  Input your name
  2.  Input your choice
  3.  ["You win!", "You lose!", "Its a draw!"].sample
  4.  Computer makes the result a reality by choosing the relevant option.
This kind of backwards way of thinking really shows how solving problems can be just as effective by giving the illusion that it does what we want when it might not. 

Like why not pick the outcome first? Who says we cant? Maybe this is how gambling sites work to make sure that they get the correct probabilities that they say they have.

Anyways I thought this was a cool thing that she did, I never really thought about doing it in that way. Oh and of course, every step was done with TDD testing all the way.

This week we are going to be working on using a database in a webapp, seems pretty heavy. Should be some interesting stuff... Until next week, have a great week dudes!

When the cat says no coding allowed...

No comments:

Post a Comment

Add this