GithubHelp home page GithubHelp logo

visma-task's Introduction

Visma - Request identifier

Visma solutions - programming task, Summer Trainee 2023

View my solution and unit tests!

Description

I understood the problem as primarily a string parsing problem, that should be as secure as possible and not allow invalid inputs. I used test-driven development in my solution, first writing unit tests based on the requirements in the specification. My solution satisfies these requirements clearly, only allowing valid URIs.

I wanted to use TypeScript, since that's the language I'm most familiar with. I'm very familiar with OOP and classes from Scala and Python, but I hadn't used classes in TypeScript before, thus I first wrote an initial solution using functional programming, and then converted that into a class with OOP paradigms, using access modifiers and making my methods private, and values readonly.

I also tried to make my solution as flexible as possible. Now, it is easy to edit valid schemes, paths and params in just one place types.ts and extend the switch case for validating params in validateParams.

I would've liked to also generate the validateParams function from the type definitions, but this quickly became too complicated for this simple assignment, that I cut some corners here.

I also compromised in what feedback I give in the error message, when parsing parameters fails. Now I only return back the parameters, but do not specify the exact reason (e.g. invalid type).

I didn't implement a client for the class, since I found it makes more sense in this case to just write a couple of unit tests for the class business logic. This better showcases what the class is supposed to do, along with the doc-comments.

Regex?

I debated using Regex for the solutions, but decided against it, since readability and cleanliness were main evaluation criteria. And since Regex is bad practice, when there are clearer built-in solutions, like str.split().

Testing my solution

  # install pnpm
  npm install -g pnpm@7

  # install dependencies
  pnpm install

  # run tests
  pnpm test

  # build library
  pnpm build

visma-task's People

Contributors

mikaelsiidorow avatar

Watchers

 avatar  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.