OregonStateUniversity / fs-ops-normal

Forest Service initial attack hose & equipment estimator for wildland fires.
3 stars 1 forks source link

ModifyEstimateScreen: Extract row widgets into custom widget class. #248

Closed ybakos closed 1 year ago

ybakos commented 1 year ago

Now that the screen is fairly feature-complete, it can be improved. This class exhibits duplication and also reveals an opportunity to introduce new abstractions / data structures to eliminate the duplicate code. It is a larger refactoring, so deprioritize until later (may warrant some discussion).

aimeekb commented 1 year ago

ModifyEstimateListScreen: refactor

ybakos commented 1 year ago

In ModifyEstimateScreen, the author has created functions for each "row", which returns a Row widget. Notice how these function implementations are nearly all the same.

Create a new standalone Widget subclass, eg EstimateItemRow, that is parameterized to accommodate "what is different" in the existing functions.

Suggested steps:

  1. Define the Widget subclass, and replace return Row in trunkLineRow with return EstimateItemRow(a, b, c). This should be a single, short statement.
  2. Do the same for latLineRow. Adjust the EstimateItemRow as necessary.
  3. Repeat for each existing function