The roller-coaster continues…
I’ve had less time to sort my projects this week and while I completed my tic-tac-toe project, I was unable to get through all of the Simon game challenge. To be honest, even with an extra day holiday tomorrow I think it’s a stretch, this rabbit hole looks to be a deep one! Here’s my freecodecamp weekend:
Deceptive! I looked at this challenge and thought it was something I could definitely get my teeth stuck into, and with my Maths background I thought it would be easy to implement a minimax formula later to have an ultimate tic-tac-toe game. So – just sort the rest out first, get a basic comp player up and running and solve later right?? Not so fast there! This challenge brought up some new problems that I hadn’t considered fully from the outset.
My biggest issue was trying to run before I could crawl. I’ve always looked at my code thinking “how can I cut this down to be more eloquent from the beginning”. This thought was particularly prevalent coming into the challenge as I spoke to someone in the industry earlier in the week. They mentioned a site called Codility, where you can test your baseline skills and see how well you compare against others in the field. The first challenge they have is a refactoring test which, tbh, I struggled with. I also know that GitHub is the place everyone goes to judge your coding ability, and if my current content was there it would be a rugged landscape of if & else statements where DRY is considered and thrown away. So I wanted to really challenge myself and write better code from the off, especially with the focus of not repeating myself….that didn’t go so well.
This was all to my disadvantage. I’ve read it before though, so it’s my own fault for not paying attention – solve the problem first, refactor later. I missed this important step and ended up really struggling to get my game to work straight away. This cost me some time in getting everything finalised, but taught me an important lesson in the meantime.
It was good to learn simple things like passing over control to the computer and vice versa. Dialog boxes were a new and annoying phenomenon to me. With codepen constantly refreshing, and the box reloading, that got tiring really quickly.
Looking over my code now as I write this blog, there are so many obvious refactoring opportunities which I think “why didn’t you do that in the first place”, but I think I should just refer to my earlier comment! I’ve decided that after my front-end certificate is over I’m going to go over my code from all my codepen challenges and refactor as much as I can. Then maybe later on in my journey I’ll refactor again as my knowledge grows and I spot new ways to improve my code. But for now, lets get this finished!
CSS still eludes me. Man I need some design lessons! It’s not where I see my skills lie and it’s not something I particularly want to master, but I do desperately need to gain some basic knowledge on this topic! Here’s my codepen:
I haven’t had an awful lot of time on this one to be honest. To date I’ve set up my buttons, sorted the css and click functions to make them appear to lighten up for a small period of time. Everything was going pretty well, until I needed to implement a delay between buttons getting called. My last blog post talked about the ups and downs I felt as I completed my earlier challenges and this was no different. I managed to call a pattern from a master array and send that to the button functions which I felt pretty good for, and then instantly I realised that an array of more than 1 just wasn’t getting called. I read this post about the issue which basically says that my code waits for no man, and just fired off all buttons simultaneously, even though I had a setTimeout call involved. Probably an hour or so in and out of the issue and then reading other blog posts, I sorted out some code, still struggled, then one typo and boom! Problem solved. I mean, I still don’t get why it wasn’t working before and now it miraculously does….but still, it works!
Now it’s dawned on me that I need to consider how I’m going to pass control to the user, test against the current pattern, give feedback, etc, etc. This one’s going to be the toughest one yet, and that’s why I don’t think I’ll be able to complete it all by the end of tomorrow. But I’ll give it a good go!
If you’ve read this far, I thank you for that and I’ll pass on some knowledge I’ve gained from this weekend – Janis Ian – At Seventeen – awesome chill out coding tune. Coupled with the Girl from Ipanema and I’m set.