Friday, December 02, 2016

CODE CLAN WEEK 10 - JAVASCRIPT... USE A SEMICOLON IF YOU WANT!

So I'm now in double figures of being a full-time coder. We have done Ruby, done Java and now we are being thrown into the deep end with JavaScript.

It's actually not that bad, lots of the concepts we have learned to date apply to JavaScript, and getting up and running making programs is quite quick. And yes as I have mentioned before Java and JavaScript are not the same languages. Java is a compiled language, JavaScript is not.


Monday morning standup had us discussing the previous week and our like for the computer science teaching, but not so much of a like for the CV and cover letter teaching. I think the latter adds some reality that we will need to get a job at the end of the course and will be competing against each other for vacancies…

 

Anyway, Monday starts with JavaScript and we are quickly learning the basics of Operators, Loops, Arrays, and Functions. All very familiar and it's amazing how quick it is to get basic programs running compared to day one Ruby.

Tuesday's standup starts with a number of cohorts commenting that so far they like JavaScript, but some comment that they don't like that it's not as strict as Java… In Java you must use a semicolon at the end of a line, JavaScript is up to you if you want to use a semicolon. Convention says to use one but hey if you forget it will carry on regardless. Nice!

In class, we start to build a bear and a robot and start to bring in modules. Modules get us back to TDD (Test-driven Development) and set up our programs so that they are tested as they are built. When making an object the first thing to construct is the associated Spec (or test file) that will define the tests for the object before you program the object.

The afternoon lab is a task to create a JavaScript water bottle and an athlete. The bottle begins empty and you have to fill it, and the athlete can drink from the water bottle and the bottle gets depleted. As the athlete runs their hydration goes down and they need to drink to replenish their hydration. Split into pairs we had about 90 minutes to create the program and have it pass tests. It was a great exercise to get two objects passing data between them.

For the homework out came the shopping basket from the previous week which was an employer coding test. Apparently one of the best ways to learn a new language is to have a familiar task that you can program in each new language. So us as homework, we had to recreate the shopping basket, add items to the basket, remove items from the basket, find the total cost of the basket, apply a discount of 10% for a total over £20, include a buy one get one free offer, and if the customer had a loyalty card give them an additional 5% off their total. So yesterday We’d never touched JavaScript before. This homework was hard and took quite a while. But on the train the next morning I had my bog-of working and all my tests passing!

Wednesday and Thursday we expanded on javascript functionality and learned how to set up objects and pass functions into functions. Seems a bit odd to pass a function into a function but after a few examples, it can be very powerful. We practised the new functionality in a couple of afternoon pair programming labs.

First, we were set the challenge to bring up a superhero object and feed them their favourite food which would boost their energy. Then they picked up an evil rat object that when they touched the food would make it poisonous and the superhero would become sick.

The second was to create a bank account and add account objects which had an owner amount and type. We practised passing functions by using predefined methods to search for a named account in the bank array, look for the highest valued account, etc.

Thursday night was quiz night hosted by Cohort 8. An excellent evening where 3 cohorts (7,8 and 9) came together with instructors and mixed into teams. My team was joint third. we did well guys the questions were tough.

So it's Friday and I'm back on the train from Stirling to Edinburgh for 10:00 am morning standup and issue of the weekend homework. Looking forward to it as I'm enjoying JavaScript.

Next week we take it into the browser and add some visualization to our programs.

It's the end of week 10 and it's been another brilliant week at Code Clan, I'm learning so much and loving writing code. Thanks again to the instructors and huge thanks to my fellow cohorts for being such an awesome bunch!

<-- Here is my ladybird book on computers when I was a Kid. Was I always destined to do something with computers?

Oh, and the word House looks odd when you read it a number of times in a row House House House House to the point it becomes unrecognizable. It was spotted by a fellow cohort during a code-along. Possibly an effect of JavaScript which was apparently written while under the influence of drink and magic mushrooms...