Giter Site home page Giter Site logo

deleting-circles-kata's Introduction

Deleting Circles Kata

The Problem

Relational databases natively support "cascade delete": in other words, if you delete an entity, its references in other parts of the database will be deleted too.

This is very helpful in more complex applications... like the one we have here.

How can we replicate this behaviour cleanly in pure frontend state?

This repo has an example animation-creation app which works like this:

  • Circles are specified globally on the right panel.
  • Keyframes, each of which is a canvas on which circles can be positioned, are specified in the timeline at the top and edited in the main view.
  • We imagine there is a render button that interpolates the keyframes and produces a finished animation.

The app is not fully functional but enough of the state is implemented for the purposes of this kata, namely adding and deleting of the related entities.

Your Mission

The app as implemented in apps/redux has an important issue. When a user deletes a shape from the global store (via the "Delete" button at the bottom of the disclosure on the right hand side), the app crashes. This is because the delete-shape reducer does not clean up references to that shape in the keyframes.

Your task: Fix the crash!

There are several considerations that form part of the challenge:

  • The existing Redux architecture is not really designed for managed entity references between entities.
  • There are no tests and the crash is a bit annoying to reproduce manually (requires several clicks).
  • The app is a single package in a rather unnecessary monorepo (this is actually entirely accidental because I wanted to try turborepo, but now I'm doubling down and claiming it is part of the challenge).

When solving, consider what architectural patterns might make cascade-delete behaviour automatic in the context of this app.

Starter Code

In apps/redux the app is implemented using just Redux and Redux Toolkit. This is your starting point.

You may wish to stick with Redux or migrate to an alternative state management framework.

Credits

The repo structure was created with Create Turbo.

Much of the boilerplate for the frontend was generated by AI tools including:

Where UI generated using v0 it is marked as such in a comment and you can click through its link to see the original prompt and generation.

deleting-circles-kata's People

Contributors

nawhi avatar turbobot-temp 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.