Skip to content

Implementing Number sequences using pseudo-generators in Javascript

Notifications You must be signed in to change notification settings

DanCarl857/js-generators

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FS-dev Sequence Generator(s)

A full stack application which creates pseudo generator functions based on sequencer functions that have been implemented here.

The back end is done in:

The front end is done in:

Design

For this project, I decided to go by way of developing a REST backend which provides data to the frontend client. I went with this particular method of design due to the following:

  • Scalability: Due to the separation of the backend(server) and frontend(client), the product can easily be scaled by any other developer
  • Portability: Again due to the separation of concerns, the server and client can be hosted on different servers.
  • Also, this particular design allowed for me to focus on one thing at every point in time and I can easily extract the generators/sequencers and use in other projects.

Work Progress

  • Worked mostly using TDD. Have 2 branches; master and develop.
  • The master branch has the best version of the code and the develop branch has the most recent changes and that's where active development takes place.
  • List of commits and work progression can be found here

Assumptions/Corners

  • I assumed the correct data will always be sent to the sequencers and as such didn't focus too much on error handling in fail cases

  • I also assumed limits when it came to the prime number sequencer(10000 prime numbers).

  • As for corners, I implemented the frontend before writing the unit tests.

  • I also hardcoded the start and step values for my range number sequencer, I did same for the partial sum sequencer. This is because taking these as parameters caused my sequencer to only return the first number and I was taking too long to debug the issue.

Production

  • Application is hosted on both Heroku and firebase(kept getting errors when hosting frontend on Heroku).
  • Frontend application is found here
  • Backend application link is :-)

Development

docker-compose up

For development, the server/ and client/ directories have their own docker containers, which are configured via the docker-compose.yml file.

The client server is spun up at localhost:3000

The local directories are mounted into the containers, so changes will reflect immediately. However, changes to package.json will likely need to a rebuild: docker-compose down && docker-compose build && docker-compose up.

Notes

Installing npm dependencies

All changes to node_modules should happen inside the containers. Install any new dependencies inside the container. You can do this via docker-compose run, but it’s easier to just update a running container and avoid having to rebuild everything:

docker-compose exec client

Then inside:

npm install --save <new_dependency>

Difficulties

  • Hosting the application on Heroku is proving difficult.
  • Implementing the logic for the piped sequence
  • Implementing Partial Sum Sequencer
  • Making full use of generators in the frontend
  • TDD for react

Future Work

  • Make API RESTful
  • Perfect and rework sequencers using actual generators or maybe I'll use async/await
  • Better the client application
  • Move client to separate repository
  • Increase code coverage in both server and client applications

Setup references

References for setting up a Node project with Docker and docker-compose:

Express + React:

About

Implementing Number sequences using pseudo-generators in Javascript

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published