Project:
View Revisions: Issue #45098 | [ Back to Issue ] | ||
Summary | 0045098: IndexedDB ApplicationState infrastructure could help developers find immutability-related issues | ||
Revision | 2020-09-21 12:32 by marvintm | ||
Description | 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) |
||
Revision | 2020-09-21 11:26 by marvintm | ||
Description | 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. |
||
Revision | 2020-09-21 11:26 by marvintm | ||
Description | 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. |
||
Revision | 2020-09-21 11:25 by marvintm | ||
Description | 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. 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. |
||
Revision | 2020-09-21 11:25 by marvintm | ||
Description | In the IndexedDB-based Application State components, actions must be immutable pure functions. 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. 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. |
Copyright © 2000 - 2009 MantisBT Group |