greyhillman / rent-vs-buy

https://greyhillman.github.io/rent-vs-buy/
GNU Affero General Public License v3.0
0 stars 0 forks source link

Refactor to MVC-like pattern #7

Open greyhillman opened 2 years ago

greyhillman commented 2 years ago

Problem

A pattern I saw emerging with components was there was 3 levels:

When a new component is added, it's not clear on where it should be placed.

Current solution

Some of the code is split into those distinctions but other parts are not.

Alternative solution

Folder structure could look like

Why no view folder?

The controllers use React hooks, which have to be called inside the render function, which is the basically the view. And React thinks in terms of components, which are a combination of view, controller, and model.

It appears to be similar to the Presentation-abstraction-control pattern.

Benefits compared to current solution

It's clearer on where the parts of a component should be placed and can lead to more code reuse by finding patterns in each section.

Costs compared to current solution

Basic dev effort.