Skip to content

[Tracking] Refactor functions with many parameters to use parameter objects #50368

Closed
12 of 12 issues completed
Closed

Description

@neil-marcellini

Problem: Many functions in the App repo have a very large amount of parameters, making it very hard to work with them. If you need some data that isn’t available with existing parameters you need to add a new one. The safe way to do that is to add it as an optional param at the end of the list. In order to pass it to the function from an existing call you have to fill in all params between the last one used and this new last param. It’s time consuming to fill out the defaults, and any required params require careful considering. Re-ordering parameters is risky and requires updating all existing calls. Also, we often have cases where we have a transaction object in the component, then call a function passing various fields of the transaction split out into n parameters. Wouldn’t it be so much easier to pass the original object? Sometimes we also pass the ID of the object in Onyx only to retrieve it from an Onyx connection later.

Solution: Gradually refactor functions to take in parameter objects, where it’s easier to re-order. Strive to minimize the number of fields. Group parameters into sensible sub-objects. Avoid duplicate prefixes such as parameters.chat.chatReport, use parameters.chat.report instead. Thrive 😄

Original Slack thread.

To do list

  • Refactor one function as an example. Maybe requestMoney or something that's less critical but has a similarly large number of parameters.
  • Update the style guide
  • Create refactoring issues
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021846632713060454080
  • Upwork Job ID: 1846632713060454080
  • Last Price Increase: 2024-10-16
  • Automatic offers:
    • dukenv0307 | Reviewer | 104452249
    • ChavdaSachin | Contributor | 104452250
    • mkzie2 | Contributor | 104791696
Issue OwnerCurrent Issue Owner: @neil-marcellini

Activity

  1. ChavdaSachin commented on Oct 8, 2024

    @ChavdaSachin
    Contributor

    @neil-marcellini we could start with IOU.getTrackExpenseInformation, IOU.shareTrackedExpense, IOU.categorizeTrackedExpense after these three IOU.trackExpense.
    These functions mostly share common data and could be refactored with ease for a start.
    I would like to work on this and following if you want external contributor to work here.

  2. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Oct 16, 2024
  3. melvin-bot commented on Oct 16, 2024

    @melvin-bot
  4. changed the title [-][Tracking] Refactor functions with many parameters to use parameter objects[/-] [+][$250] [Tracking] Refactor functions with many parameters to use parameter objects[/+] on Oct 16, 2024
  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Oct 16, 2024
  6. melvin-bot commented on Oct 16, 2024

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @dukenv0307 (External)

  7. neil-marcellini commented on Oct 16, 2024

    @neil-marcellini
    ContributorAuthor

    Sure @ChavdaSachin, please go ahead and start with only IOU.categorizeTrackedExpense

  8. 125 remaining items

  9. neil-marcellini commented on Mar 14, 2025

    @neil-marcellini
    ContributorAuthor

    We're ticking away at various sub issues

  10. neil-marcellini commented on Mar 19, 2025

    @neil-marcellini
    ContributorAuthor

    Same update

  11. neil-marcellini commented on Mar 31, 2025

    @neil-marcellini
    ContributorAuthor
  12. neil-marcellini commented on Apr 16, 2025

    @neil-marcellini
    ContributorAuthor

    I think this is basically all done now. Thanks to everyone who helped out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

EngineeringExternalAdded to denote the issue can be worked on by a contributorWeeklyKSv2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions