rpapub / PurposefulPromethium

This UiPath project demonstrates reading structured data from an email inbox, parsing the content, and automating data entry on rpachallenge.com. Designed as a tutorial basis.
Other
0 stars 0 forks source link

Refactoring monolithic legacy code #1

Open cprima opened 2 weeks ago

cprima commented 2 weeks ago

Requirements

Refactoring phases

  1. [ ] deploy Modern Design Experience with (unused) Object Repository selectors
  2. [ ] update dependencies
  3. [ ] extract initializing of applications, write testcases
  4. [ ] extract "input" data gathering (as in input-processing-output) into testable workflows
  5. [ ] streamline arguments (datatype, naming), leveraging pass-by-reference
  6. [ ] error handling
  7. [ ] identify reusability in libraries
  8. [ ] improve logging
  9. [ ] …

Learning Objectives

  1. Understand the Importance of Refactoring:

    • Explain why refactoring is necessary for long-term maintenance and scalability of RPA projects.
    • Identify common triggers for refactoring, such as bug reports, change requests, or adapting to software upgrades.
  2. Learn Criteria for Modularization:

    • Break down large, complex workflows into smaller, modular components based on logical functions (e.g., data extraction, transformation, and output).
    • Recognize the benefits of functional separation in improving maintainability, testability, and reusability.
  3. Master Parameterization for Flexibility:

    • Implement input/output argument management to make workflows configurable and reduce hardcoding.
    • Select appropriate data types (including dictionaries like in_Config and SpecificContent) to ensure workflows are flexible and adaptable to different environments and data structures.
  4. Apply Best Practices for Refactoring in UiPath Studio:

    • Refactor existing workflows by applying best practices, such as reducing code duplication, improving naming conventions, and enforcing proper error handling.
    • Use UiPath tools like Invoke Workflow, Invoke Code, and the Workflow Analyzer to streamline the refactoring process.
  5. Introduce Unit Testing in RPA Projects:

    • Understand the purpose and structure of unit tests in RPA workflows.
    • Implement basic unit tests using UiPath's native testing features or custom testing frameworks to ensure workflow correctness after refactoring.
  6. Enhance Code Quality Using Static Code Analysis:

    • Utilize the Workflow Analyzer to identify and address potential issues in the RPA codebase.
    • Interpret Workflow Analyzer results and apply fixes to improve code quality and reduce technical debt.
  7. Utilize ChatGPT and AI Tools for Refactoring Assistance:

    • Understand how AI tools like ChatGPT can assist in refactoring tasks, including code generation, modularization suggestions, and debugging.
    • Learn how to validate AI-generated code within the context of UiPath.
  8. Refactor with Error Handling and Logging Improvements:

    • Refactor workflows to include robust error handling using Try-Catch blocks and meaningful log messages.
    • Design workflows that provide clear, serviceable logs, making debugging easier in production environments.
  9. Practice Incremental Refactoring:

    • Learn how to apply refactoring gradually and safely to minimize disruption, particularly when working on production systems.
    • Explore techniques for testing changes in isolation, ensuring that refactored components do not break existing functionality.
cprima commented 7 hours ago

Regarding

[x] come up with 2-person Git flow to simulate a code review with Workflow Analyzer

The Git Repository Snapshot Archiver creates a collection of repository snapshots, for unzipping on the reviewer's system and conflict-free UiPath Studio demonstration. Prevents the necessity to switch branches which UiPath Studio does not seamlessly support.

cprima commented 6 hours ago

When to refactor

cprima commented 6 hours ago

Obstacles