Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
3 tasks
neil-marcellini opened this issue Oct 7, 2024 · 49 comments
Open
3 tasks
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Overdue

Comments

@neil-marcellini
Copy link
Contributor

neil-marcellini commented Oct 7, 2024

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. 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: @dukenv0307
@ChavdaSachin
Copy link
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.

@melvin-bot melvin-bot bot added the Overdue label Oct 16, 2024
@neil-marcellini neil-marcellini added the External Added to denote the issue can be worked on by a contributor label Oct 16, 2024
Copy link

melvin-bot bot commented Oct 16, 2024

Job added to Upwork: https://www.upwork.com/jobs/~021846632713060454080

@melvin-bot melvin-bot bot changed the title [Tracking] Refactor functions with many parameters to use parameter objects [$250] [Tracking] Refactor functions with many parameters to use parameter objects Oct 16, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 16, 2024
Copy link

melvin-bot bot commented Oct 16, 2024

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

@melvin-bot melvin-bot bot added Daily KSv2 and removed Overdue Weekly KSv2 labels Oct 16, 2024
@neil-marcellini
Copy link
Contributor Author

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

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 16, 2024
Copy link

melvin-bot bot commented Oct 16, 2024

📣 @dukenv0307 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

Copy link

melvin-bot bot commented Oct 16, 2024

📣 @ChavdaSachin 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@ChavdaSachin
Copy link
Contributor

Sounds good...

@ChavdaSachin
Copy link
Contributor

I am OOO for 2 days on an emergency business , will start working as soon as I am back.

Copy link

melvin-bot bot commented Oct 22, 2024

@neil-marcellini, @ChavdaSachin, @dukenv0307 Huh... This is 4 days overdue. Who can take care of this?

@melvin-bot melvin-bot bot added the Overdue label Oct 22, 2024
@ChavdaSachin
Copy link
Contributor

work in progress.

Copy link

melvin-bot bot commented Oct 24, 2024

@neil-marcellini, @ChavdaSachin, @dukenv0307 Still overdue 6 days?! Let's take care of this!

Copy link

melvin-bot bot commented Oct 28, 2024

@neil-marcellini, @ChavdaSachin, @dukenv0307 10 days overdue. I'm getting more depressed than Marvin.

@neil-marcellini
Copy link
Contributor Author

How's it coming along?

@ChavdaSachin
Copy link
Contributor

hi @neil-marcellini sorry for the delay, I am actually trying to implement it on a scale - coz all tracking functions are closely tied together, So I am figuring the whole network these functions have and refactor all at once so that would be a significant improvement and then all tracking related function would probably accept somewhere around 5-7 props that's it.
But it is taking time coz network is bigger.

I figured refactoring only one function - IOU.categorizeTrackedExpense would not be much of improvement so...
Let me take my time and trust me you would love the results.

Probably switch it to weekly.

Copy link

melvin-bot bot commented Oct 30, 2024

@neil-marcellini, @ChavdaSachin, @dukenv0307 12 days overdue now... This issue's end is nigh!

@neil-marcellini
Copy link
Contributor Author

Hi @ChavdaSachin. I appreciate your desire to tackle it all at once, but it's a lot easier for everyone involved if we do it in pieces. It will be faster to get the PR up for review and get it approved. I rather have many small PRs than one big one. Could you please split up your existing work into several PRs?

@neil-marcellini
Copy link
Contributor Author

Sweet, here's the issue Refactor createDistanceRequest to use a parameter object.

@Shahidullah-Muffakir
Copy link
Contributor

Hi @neil-marcellini,

I see others are working on migrations. Is there another function I can help refactor to use a parameter object? Let me know!

Thanks!

@ChavdaSachin
Copy link
Contributor

@neil-marcellini next I could work on IOU.shareTrackedExpense function, could you creat new issue?
Thank you

@ChavdaSachin
Copy link
Contributor

@neil-marcellini bump on above^

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Dec 13, 2024
@melvin-bot melvin-bot bot changed the title [$250] [Tracking] Refactor functions with many parameters to use parameter objects [HOLD for payment 2024-12-20] [$250] [Tracking] Refactor functions with many parameters to use parameter objects Dec 13, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Dec 13, 2024
Copy link

melvin-bot bot commented Dec 13, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Dec 13, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.75-6 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-12-20. 🎊

For reference, here are some details about the assignees on this issue:

@dukenv0307
Copy link
Contributor

BugZero Checklist:

  • [Contributor] Classify the bug:
Bug classification

Source of bug:

  • 1a. Result of the original design (eg. a case wasn't considered)
  • 1b. Mistake during implementation
  • 1c. Backend bug
  • 1z. Other: Refactor function

Where bug was reported:

  • 2a. Reported on production
  • 2b. Reported on staging (deploy blocker)
  • 2c. Reported on a PR
  • 2z. Other:

Who reported the bug:

  • 3a. Expensify user
  • 3b. Expensify employee
  • 3c. Contributor
  • 3d. QA
  • 3z. Other:
  • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

    Link to comment: This is the refactor issue so no need for offending PR

  • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

    Link to discussion: N/A

  • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again. Yes

Regression Test Proposal Template
  • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

    Link to issue:

Regression Test Proposal

Test:

Do we agree 👍 or 👎

@dukenv0307
Copy link
Contributor

@neil-marcellini Can you take a look at this comment? The PR here was merged for this issue already.

@mkzie2
Copy link
Contributor

mkzie2 commented Dec 17, 2024

@neil-marcellini Next I think we can do with buildOptimisticTransaction (21 parameters).

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Dec 20, 2024
Copy link

melvin-bot bot commented Dec 20, 2024

Issue is ready for payment but no BZ is assigned. @OfstadC you are the lucky winner! Please verify the payment summary looks correct and complete the checklist. Thanks!

@OfstadC
Copy link
Contributor

OfstadC commented Dec 20, 2024

Payment Summary

@OfstadC OfstadC closed this as completed Dec 20, 2024
@dukenv0307
Copy link
Contributor

@OfstadC I reviewed 2 PRs on this issue: #52231, #52221. I think we should create 2 separate issues as I mentioned here same as what we did for #53789 and others. If we decide to pay 2 PRs in this one, I should be paid 500$. Can you please check again? Thanks 🙏

@neil-marcellini
Copy link
Contributor Author

Re-opening because this is a tracking issue for the project. Let's handle payment going forward in the separate sub-issues.

@neil-marcellini neil-marcellini changed the title [HOLD for payment 2024-12-20] [$250] [Tracking] Refactor functions with many parameters to use parameter objects [Tracking] Refactor functions with many parameters to use parameter objects Dec 23, 2024
@neil-marcellini
Copy link
Contributor Author

Hi, I created these two new issues and tagged you guys there. Please comment so I can assign. @dukenv0307 moving forward I'm going to let C get automatically assigned, because these PRs tend to be easier reviews and I think it's fair to spread those among other C now.

Refactor buildOptimisticTransaction to use a parameter object
Refactor shareTrackedExpense to use a parameter object

@dukenv0307
Copy link
Contributor

dukenv0307 commented Dec 23, 2024

@neil-marcellini And then can you create a separate issue for that PR.?Thanks

Copy link

melvin-bot bot commented Dec 27, 2024

@OfstadC, @neil-marcellini, @ChavdaSachin, @dukenv0307, @mkzie2 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@melvin-bot melvin-bot bot added the Overdue label Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Overdue
Projects
None yet
Development

No branches or pull requests

6 participants