the page - Time to render the page - Need to reload the all components when a state is changed Maintainability Refactoring background: Software product quality - No specification document - Complicated logic - No testing code - State Management • Search options • Delivery address (Block-code) • Standard or Schedule delivery
component Implement universal links and AppLinks Free shipping campaign Integrate new Ads API with the page Recommend shops feature UI, UX PJ Business PJ Refactoring background: Software product quality Maintainability Usability Can we handle bigger PJs?
List Recommend Banner Order history Header Generate Shop List Data Set Generate Chain List Data API - Specific shop list - Chain store - Recommend shops - Order history - Banner Problem of the shop list screen: Data flow
list screen APP Format Shop data (Domain Logics) Shop List Recommend Banner Order history Header API Over 300 Lines in 1 function ! Problem of the shop list screen: Data flow - Specific shop list - Chain store - Recommend shops - Order history - Banner
delay • Implement paging • Recode the processes that depend on the responses • Problem: Complex data flow • Redefine each API responsibility • Move the data flow to a BFF layer • Problem: Legacy class component implementation • Use function components instead of class components • Split components • Separate UI and business logic by using hooks Data flow Legacy React architecture Data fetching
List Recommend Banner Order history Header Generate Shop List Data Set Generate Chain List Data API - Specific shop list - Chain store - Recommend shops - Order history - Banner Format Shop data (Domain Logics)
Shop search Specific shops Chain store Approach to problems: Data flow - Specific shop list - Chain store - Recommend Shops - Order history - Banner Format Shop data (Domain Logics)
Shop search Recommend Banner Order history BFF Shop list Specific shops Chain store Approach to problems: Data flow Specific shops Chain store - Specific shop list - Chain store - Recommend shops - Order history - Banner Format Shop List Format Specific Shops Format order history Format recommend Format banner Format chain store
hooks - Data fetch logic - Unit Testing Class Components - Rendering logic - Data fetch logic - Unsafe Lifecycle Function - Difficult to split UI and business logic - No testing code Function components - Rendering logic - Snapshot Testing React hooks - Lifecycle logic - State logic - Unit Testing Approach to problems: Legacy React architecture
React architecture Recommend Banner Order history BFF Shop list Specific shops Chain store Format Shop List Format Specific shops Format order history Format recommend Format banner Format chain store
delay • Improve test coverage Architecture Performance • Use function components • Use a more declarative UI style Others • Remove unnecessary features • Motivate developers
Chain store Refactoring Results: Architecture Recommend Banner Order history BFF Shop list Specific shops Chain store Format Shop list Format Specific Shops Format order history Format recommend Format banner Format chain store
Shop List Data Set Generate Chain List Data Before - Specific shop list - Chain store - Recommend - Order history - Banner Refactoring Results: Architecture