Giter VIP home page Giter VIP logo

crossmintchallenge's Introduction

Ariel Umansky

Crossmint Challenge

Getting started

This is a plain node project using babel to compile tests. This uses ecmascript 6 so a node version greater than 13 is required.

A simple npm install + npm test should do it.

If for some reason a compilation is needed, just type: ./node_modules/.bin/babel src --out-dir lib

Challenge Description

There are mainly two abstractions:

  • MegaverseApi: Which encapsules all the technical details necessary to deal with Challenge API
  • MegaverseChallenge: Which acts as a director of the challenge and execute the actions needed to pass it

On top of that, I TDD'd a mocked version of the MegaveseApi, that runs on memory, in order to be able to test the whole thing without actually pinging the real API.

Refactors

I considered a couple of refactors. For example, in the following snippet from the MegaverseChallenge#executeCurrentGoal method:

if(value === MEGAVERSE_CODE_NAMES.POLYANET) {
    createOperations.push(this.megaverseApi.createPolyanet(rowIndex, columnIndex))
}

const additionalParam = value.split('_')[0].toLowerCase()

if(value.includes(MEGAVERSE_CODE_NAMES.SALOON)) {
    createOperations.push(this.megaverseApi.createSaloon(rowIndex, columnIndex, additionalParam))
}

if(goal[rowIndex][columnIndex].includes(MEGAVERSE_CODE_NAMES.COMETH)) {
    createOperations.push(this.megaverseApi.createCometh(rowIndex, columnIndex, additionalParam))
}

in order to avoid the successive if (that could get cumbersome if there're more types of entities in the future), I could have delegated on specific classes for each type and have some sort of object composition in place. Those classes could also help with the condition in MegaverseChallenge#passesGoal method. However, I thought that this approach was a little over-engineered, and since simplicity was key, I left it as is. Also, for the size of the challenge, I think is more readable this way.

Side notes

  • I completed and validated the challenge while still implementing refactors, so I couldn't access the map API to figure out goal#2 response structure. I ended up assuming them. I commented accordingly in each place that happened.
  • Integration tests are bypassed because the API stopped responding after completing the challenge.

And that's it. Feel free to ping me if you need further clarification!

crossmintchallenge's People

Contributors

arielumansky avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.