- Intro
- Challenge Definition
- Notes and Questions
- Continuous Integration
- Developer Quick Start
- Full Development Instructions
- Development Thoughts
A javascript utility to score a bowling game interactively. Created for a challenge provided as part of the interview process for a software engineering position.
Create an application to score a bowling game, first for a single player and then for multiple players. Full challenge details
The basic version was completed at hash 1171112
I decided to use JavaScript to complete this challenge as I’ve been wanting a good small problem to write functional JS and I have also wanted to use ES6 (ES2015). This code is my first interactive JS program and the first time I have done a purely functional javascript approach. I'm proud of what I've produced here, but I’m sure there are improvements that can be made.
The one thing I would raise for code review is a question, am I being too clever with the scoring by keeping it all as a string for each player? More generally, should the data structure contain more explicit data such as current player turn, frame, ball number, etc? If I had been developing this with a team I would definitely have talked over this design aspect with team members. On one hand I really like how it turned out, but I’m not sure if I’m sacrificing code readability.
Travis CI is running continous integration for this project at https://travis-ci.org/billingb/bowling-scorer
for full instructions see the "Full Installation Instructions" at the bottom of this page
- node.js version 4 or newer (this project uses ES6)
npm install
to fetch the dependenciesnpm start
- Run
npm install
to fetch the dependencies
- Run
npm run lint
- Run
npm test
ornpm test:watch
This program requires the node.js JavaScript runtime and node package manager (npm). A good beginners guide for these technologies is available at https://nodejs.org/en/about/. There are a few options for installing the runtime:
- (Mac OS X and Linux): Install node using nvm (node version manager): https://github.com/creationix/nvm. This option is nice because it allows you to switch versions. If using nvm install a 4.x version, preferably 4.3.1 which this code has been tested against.
- (Mac OS X): Install node by downloading the pre-built binary available at https://nodejs.org/en/. A nice tutorial is available at http://coolestguidesontheplanet.com/installing-node-js-on-osx-10-10-yosemite/
- (Linux): Many linux distros have packages available through a package manager. Details on installing using a package manager can be found at https://nodejs.org/en/download/package-manager/
- (Linux): Node.js provides pre-built tarball on the webpage https://nodejs.org/en/, this is a good guide to this and some other options for installing on linux (ubuntu focused): http://www.hostingadvice.com/how-to/install-nodejs-ubuntu-14-04/#standard-binary-packages
After installing make sure node and npm are on the path by running node -v
and npm -v
. If either of these commands
fails then something went wrong in the installation. Recheck that the node and npm executables are in place and you have
added them to your path.
After NPM is installed execute npm install
to install all the dependencies for this application.
To run the program execute npm run exec
This application was written using test driven development (TDD) with the Mocha test framework (https://mochajs.org/)
and the Chai Assertion Library (http://chaijs.com/). The tests are all written using the should syntax provided by
Chai. There are unit and acceptance tests, with the acceptance tests in a file Acceptance_spec.js and all other spec
file containing unit tests. To run the tests execute npm test
. To run the tests in watch mode, so they will re-run
whenever a file is changed, execute npm run test:watch
When developing on this application the linter, jshint (http://jshint.com/docs/) should be run to help keep the
code clean. JSHint can be run by executing npm run lint
This is the second application I have had the opportunity to use the new ES6 standard for. I wanted to take this opportunity to learn more about the new language features that have been introduced and start getting comfortable with those features. I still have some inconsistency in using the new features and figuring out how they best fit, for instnace I use the arrow functions in the code (=> syntax) but in the tests I wrote the older syntax in the it and describe lines.
I wanted to use a functional style in this program as I have been learning Clojure lately and really like the functional paradigm. I decided to use Immutable.js (https://facebook.github.io/immutable-js/) to get Clojure style data structures that are much safer to write functional code with since they prevent accidental side effects.