Giter Site home page Giter Site logo

cardiologs-interview's Introduction

CardiologsInterview

This project is my solution to Cardiologs Interview Homwork.

This is my first Angular project and my first time with TypeScript. I've tried to write idiomatic code in respect with those technologies, please be lenient if I failed ๐Ÿ‘ผ.

Development server

Run the server project on http://localhost:3000/ (this should be the default if you npm run api).

Run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Data Flow

The project structure strictly follows The Elm Architecture (fr) (which sensibily influenced the Redux Pattern in the JS/React world).

The basic idea is to store all the application state in a central place and purely derive the view from this state. Then, the view can generate some messages (or events, or actions) which updates the state (and the view automatically is updated from this new state).

TDD

I've used the Types Driven Development technique to develop this application, trying to make "impossible states impossible" as much as possible.

E.g., the patients field of my model is not a an array of patients. This is either LoadingPatient, ErrorPatient or LoadedPatient. Only the LoadedPatient type has a patients array and TypeScript prevent us to access this array if the data are not loaded.

The data coming from the server are "unsafe": we are not sure they are in the shape we expect. That is why I've build decode functions to translate from this "unsafe" world to the "safe" one (a.k.a TypeScript types). I should write tests for thoses functions, since they are really error prone (but, hey! I've already consumed all the time budget for this homework!). (In elm, it is really easy and safe to write such functions, but it didn't find such similar wide adopted lib in TS.)

Those decode functions represent failure by returning null. It would be more appropriate to use some kind of Result type to express why the decoding fail, but it seems a bit complicated to use in practice since each TS lib use its own Result version, so I used a simple null ๐Ÿคทโ€โ™‚๏ธ.

Build

Run ng build to build the project. The build artifacts will be stored in the dist/ directory. Use the --prod flag for a production build.

cardiologs-interview's People

Contributors

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