Skip to content

psnev89/flatfair-challenge

Repository files navigation

Flatfair Challenge

Tried to step out of my confort zone and attemped to complete this challenge using TypeScript.

Checking the Organisation Structure, quickly noticed that the best way to represent it was by using the Composite Design Pattern, with the Branch being the Leaf node and the other types (Area and Division) being a Composite node. Decided to split into different classes for SOC and scalability reasons.

Organisation Unit diagram

As the main goal was to implement the calculateMembershipFee function, I implemented it on the index file. On a "real" app, I would have implemented it on a domain layer, along with the validations, and have separate layers for data and UI (multi-repo maybe?).

Considerations for future iterations

  1. Validate invalid Membership fees (negative or NaN).
  2. Mock organisation data and add calculateMembershipFee function tests.
  3. Move main function to a domain related folder along with the validations.
  4. Add simple UI to allow user interaction.
  5. Add the Client Organisation Unit (didn't add as it was not referred as an Organisation Unit in the challenge).
  6. Validate invalid function inputs (despite TypeScript already helping with that a bit).

Install

This project uses node and npm.

$ npm install

Usage

To run tests:

$ npm run test

To compile and run an example:

$ npm run start
# it will compile to dist/ folder

Business rules

BR Description
BR1 rent amount should be between 1 - int.max
BR2 rent period should be one of ["month", "week"]
BR3 calculate membership fee function should throw or return error when rent amount is invalid
BR3.1 allowed rent amount for week rent period should be [25£ ~ 2000£]
BR3.2 allowed rent amount for month rent period should be [110£ ~ 8660£]
BR4 monetary amounts are stored in pence

PS: sorry for my english, I'm really looking forward to improve it!

About

Flatfair challenge

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published