Openbravo Issue Tracking System - Retail Modules
View Issue Details
0045098Retail ModulesWeb POSpublic2020-09-21 11:252022-02-01 08:07
marvintm 
Triage Platform Base 
normalmajorhave not tried
newopen 
5
 
 
No
0045098: IndexedDB ApplicationState infrastructure could help developers find immutability-related issues
In the IndexedDB-based Application State components, actions must be pure functions that should not mutate any parameter they receive. This is a very important requirement which is the base for the new layer implementation, and responsible for most of the benefits it provides.

However, when developing those actions, it is easy to forget this requirement, and therefore easy to make mistakes. At the same time, those mistakes are not immediately obvious in many cases, and therefore they are easy to miss, and may end up in development code causing bugs and regressions.

There is one improvement that could be implemented, that would greatly help developers to detect these mistakes, so they can fix them. It would consist on the following:

- When working in development mode, we could freeze the application state (using deepFreeze library)
- In development mode, when executing actions we could run the code in strict mode

With these two changes, any mutation of any property at the state, at any level, would immediately produce a Javascript error. This would be great because developers would immediately notice the problem.

At the same time, it is important to do this only in development mode, as it has an associated performance impact which we don't need to pay when running in production environments.

The main idea is to deepFreeze both of:
- The main application state (including all state properties)
- The payload in action execution (this is to prevent silly mistakes that we saw in the related issue)
- Implement an action that mutates the state
- Realise that in most cases, if you dispatch the action the mutation takes place but you don't realise it.
No tags attached.
related to defect 0045016 closed Retail state actions mutate objects 
Issue History
2020-09-21 11:25marvintmNew Issue
2020-09-21 11:25marvintmAssigned To => platform
2020-09-21 11:25marvintmTriggers an Emergency Pack => No
2020-09-21 11:25marvintmDescription Updatedbug_revision_view_page.php?rev_id=21719#r21719
2020-09-21 11:26marvintmDescription Updatedbug_revision_view_page.php?rev_id=21720#r21720
2020-09-21 11:26marvintmDescription Updatedbug_revision_view_page.php?rev_id=21721#r21721
2020-09-21 11:28marvintmRelationship addedrelated to 0045016
2020-09-21 11:44hgbotNote Added: 0123260
2020-09-21 12:32marvintmDescription Updatedbug_revision_view_page.php?rev_id=21722#r21722
2022-02-01 08:07alostaleAssigned Toplatform => Triage Platform Base

Notes
(0123260)
hgbot   
2020-09-21 11:44   
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.mobile.core/-/merge_requests/76 [^]