ShuffleDeck
This started off as a coding challenge from a pretty cool company. The challenge was: Write a simple class in the language of your choice to represent a deck of cards with operations to shuffle the deck and to deal one card.
This was a great challenge because it inspired me to really consider the architecture involved in producing a class hierarchy. Because my primary language of choice is JavaScript which is not traditionally a class based language, I felt really challenged in the 'philosophy' of how to construct the deck. Would I want just a simple deck of cards? Or would I rather design the hierarchy to include a myriad of card decks for different games?
I utilized the power of class instantiation despite my feelings of how brittle it makes code structure, and felt that I produced a decent model to implement into something useful. I refrained from utilizing the new ES6 class keyword and instead stuck to solely using the constructor, this decision was made simply because I was on a time constraint and have not invested the proper time to have full confidence in the sugar of the class keyword. Refactoring will take place if I find it necessary/optimal. Furthermore, because the majority of people I have learned from whom I consider authorities on the subject of JavaScript tend to stay away from hierarchy patterns, I decided to double up and create an OLOO (objects-linked-to-other-objects) version of the card deck. In a work environment, I imagine this decision would be made by those superior to me or in consensus with my teammates after code style and approach were discussed.
I created testing for both styles (OLOO and Class instantiation) which made the actual coding fairly simple once my tests were up and running. Having had so much fun with this challenge, I've decided to build an app around this concept. I'm hoping to have the MVP up and running by September 20th, 2016 (time permitting) on http://warwithchevy.herokuapp.com/. The app will have a React front end, an authorization, simple games like draw a card, War, and rock-paper-scissors. In addition, a database will be developed in SQL so users can save/bury the cash they didn't blow on rock-paper-scissors and store statistics. The code for this will be at https://github.com/richardjboothe/Chevy_Chase_Goes_To_War if you'd like to follow along.
To run the tests, simply install the node_modules via the command line by typing: npm install, after installing simply type npm test!