A simple calculator using HTML, CSS and JavaScript. The basic idea of this project is to implement a javascript application following the ground rules:
- modular code
- separation of concern
- loosely coupled
- encapsulate
- testable
Publish–subscribe pattern is used to make the application loosely coupled. AMD pattern is followed using dojo for scalable application. Unit and functional tests are written using Intern.
Requirements
- Node package manager
- Please refer to the
package.json
file for dependencies.
How to run
- Clone the project
- Run
npm install
from thesimple_calculator
directory to download and install the dependencies. - Open
simple_calculator/src/index.html
in a browser window - Optional
- run
npm start
to run the node server - look at the console message for the host address
- run
How to test
- Run
npm test
from thesimple_calculator
directory to run the test cases. - Apart from the console output, the code coverage results will be stored in
simple_calculator/tests/reports
. - After running the tests, open
simple_calculator/tests/reports/index.html
in a browser window to look at the results.
Courtesy and useful links
- Styled following the instructions at http://thecodeplayer.com/walkthrough/javascript-css3-calculator.
- Basic publish-subscribe pattern in javascript at https://gist.github.com/learncodeacademy/777349747d8382bfb722.
- Modular javascript tutorial series https://www.youtube.com/playlist?list=PLoYCgNOIyGABs-wDaaxChu82q_xQgUb4f.
- Publish-subscribe pattern basics http://learning-0mq-with-pyzmq.readthedocs.io/en/latest/pyzmq/patterns/pubsub.html.
- Intern JavaScript test plugin https://theintern.github.io/.
- jQuery (write less, do more) https://jquery.com/.
- AMD
- Why Choose Dojo?
- How to Unit Test Private Functions in JavaScript by Philip Walton https://philipwalton.com/articles/how-to-unit-test-private-functions-in-javascript/. Many other important topics are covered in his blog https://philipwalton.com/.
- Some books:
- Learning Javascript Design Script Patterns by Addy Osmani.
- Pro JavaScript Design Patterns by Dustin Diaz and Ross Harmes.
- Dealing with numbers in javascript: