Wflow.jl icon indicating copy to clipboard operation
Wflow.jl copied to clipboard

Refactor: initialize function, (long) structs, `Model` struct fields

Open alimeshgi opened this issue 1 year ago • 3 comments

Feature type

Changing existing functionality

Improvement Description

The current implementation contains long and complex initialization functions and data structures, leading to code redundancy, reduced maintainability, and potential performance issues. To address these issues, it's essential to reorganize initialize functions, divide lengthy structs into smaller sub-structs, and refactor data storage within the Model struct for improved organization and clarity.

Implementation Description

  1. Initialize Function Refactoring: Breakdown Long Functions: Separate long initialization functions into smaller, more manageable sub-functions based on logical units of functionality. This will enhance code readability, maintainability, and ease of debugging. Explicit Content Descriptions: Ensure that each sub-function has clear and explicit descriptions of its purpose and functionality to aid understanding and documentation.

  2. Struct Refactoring: Divide Lengthy Structs: Divide lengthy structs into smaller sub-structs to minimize overlap and improve modularity. This will make the codebase more organized, easier to navigate, and reduce the risk of errors. Extract Shared Components: Identify shared components within the structs (e.g., interception, snow, glacier) and pull them out into separate structs or modules to promote code reuse and maintainability. Consider Decoupling: Reorganize long structs to decouple vertical and horizontal concepts, ensuring a more modular and flexible architecture.

  3. Data Storage Refactoring: Use Structs for Data Storage: Refactor the storage of network, vertical, and lateral fields within the Model struct, replacing NamedTuples with Structs for better organization and readability. Explicitly define the contents of each struct member to enhance clarity and maintainability.

Additional Context

No response

Task overview

  • [ ] #382
  • [ ] #383
  • [ ] #326
  • [ ] #243
  • [ ] #225
  • [ ] #348

alimeshgi avatar Feb 09 '24 13:02 alimeshgi

Issue #326 is linked to this refactor, and should be discussed in the design session

JoostBuitink avatar Mar 21 '24 09:03 JoostBuitink

#243 is also linked to this, and should be done in parallel

JoostBuitink avatar Mar 21 '24 09:03 JoostBuitink

Also issues https://github.com/Deltares/Wflow.jl/issues/225 and https://github.com/Deltares/Wflow.jl/issues/348 should be considered in the design session/ refinement.

verseve avatar Mar 21 '24 12:03 verseve