codeforboston / codeforboston/cliff-effects
Explore new 'shelter' data structure
- Dominant language
- JavaScript
- Stars
- 30
- Forks
- 62
- PR merge metrics
- No merged PRs in 30d
Description
The current ways of accessing shelter values are very fragile. Possibility for more robust data structure:
```js
client.current = {
shelter: 'homeless',
renter: {
rent: 1530,
rentShare: 0,
contractRent: 0,
mortgage: 0,
housingInsurance: 0,
propertyTax: 0,
climateControl: true,
nonHeatElectricity: false,
phone: true,
fuelAssistance: false
},
homeless: {
// same
},
homeowner: {
// same
},
hasHousing: {
// same
}
}
```
Using the new data structure:
```js
let timed = client[ timeframe ],
shelterVals = timed [ timed.shelter ],
mortgage = shelter.mortgage,
insurance = shelter.housingInsurance,
tax = shelter.propertyTax,
houseExpenes = mortgage + insurance + tax;
```
How it would work with inputs: When a user selects 'renter' only the `rent` properties would be changed. If they select 'homeowner', only the `homeowner` properties would be changed. Etc.
The point? Right now calculation functions have to check which type of shelter is in play and then get the correct values for that shelter. With this change, they don't need to do any of that, and they'll still be able to do the old checks if they need to (for example, they can check if the client is homeless).
Now that we have the ability to set and access nested values, this could be our best, and a great, option.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.