Skip to content

A small demo to showcase a legacy code refactoring process

Notifications You must be signed in to change notification settings

varholak-peter/refactor-demo

Repository files navigation

Refactor Demo

This should serve as a how to guide on refactoring legacy code into its modern counterpart.

Note: This demo uses React.

Task specification

Change <AutocompleteAddress /> map service from Google Maps to Mapbox while maintaining backwards compatibility.

GIVEN: I am a developer.

WHEN: I want to use the <AutocompleteAddress /> component.

THEN: I am able to use the Mapbox API.


GIVEN: I am a developer.

WHEN: I am using <AutocompleteAddress /> component in a legacy app.

THEN: Nothing breaks once I update the component library.

How this repository works

The refactoring part lives in the refactoring branch. (git checkout refactoring)

The steps to follow are described in the refactoring/CHANGELOG.md. Each step is a separate commit in that branch so you can explore how the code changes over time by checkouting to different commits.

Folder structure

This repository is split into 4 folders: legacy, refactored, refactoring and shared.

Legacy

Legacy folder represents the starting state of the codebase for reference.

This is a minimal representation of the src folder in a component library.

Refactored

Refactored folder represents the final state of the codebase for reference.

This is a minimal representation of the src folder in a component library.

Refactoring

Refactoring folder represents the step by step process of refactoring according to task specification.

This is a minimal representation of the src folder in a component library.

Shared

Shared folder contains dummy mocks of dependencies, which the rest of the codebase uses.

Prerequisites

Getting Started

Run the following script:

git clone https://github.com/varholak-peter/refactor-demo.git

Once you clone the repository run the following command to verify the installation:

cd refactor-demo
yarn && yarn test

Useful commands

yarn test

Runs all tests.

yarn test:legacy

Runs legacy test suite.

yarn test:refactored

Runs refactored test suite.

yarn test:refactoring

Runs refactoring test suite.

CONTRIBUTING

Contributions are always welcome, no matter how large or small. Before contributing, please read the code of conduct.

About

A small demo to showcase a legacy code refactoring process

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published