Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8605071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:44:00+00:00 2026-06-12T02:44:00+00:00

I have 34 different methods that take 1 parameter of my ViewModel class, but

  • 0

I have 34 different methods that take 1 parameter of my ViewModel class, but each of them only uses two or three properies on the class. I think I’d rather just pass those properties to these methods instead of the entire object. Is that a way to easily refactor that? I tried to just select all the text inside my function and do Refactor > Extract Method hoping it would be smart enough to see that only 2 properties of the object were being used and make the parameter list just those 2 properties, but it just wanted to take the whole object again.

Maybe I need to explain what I’m doing…

I’m trying to write an application that will generate text for a wiki page. Based on the values entered into the UI it will either generate text for a template and text for using that template, or it will just generate the text for the page if a template isn’t necessary. There are 17 different parts to it so there are 17 functions that, when combined, create the text of the template page, and there are 17 functions that combine to make the actual page if a template isn’t needed. I did it this way so I can test smaller pieces of it at a time instead of testing the entire output of one massive function.

So currently all 34 of those methods take 1 parameter, the whole object that’s built from the UI. To me that doesn’t make sense any more. A function that generates 1 section of the entire page will never need to know about the data that’s used in a different section, and if anyone does try to use it there then I know something’s wrong.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:44:01+00:00Added an answer on June 12, 2026 at 2:44 am

    Is there a reason not to pass the object? Objects are passed by reference and it’s quite efficient, plus if your implementation needs more properties, it’s easy to modify the function than to maintain the function declaration and go after all the callers. I’d be inclined to leave it alone.

    But to answer your specific question, I don’t know of a way to refactor it in Visual Studio. That’s another part of why I’d be inclined to leave it alone if it’s working. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi i have a class which contains different methods for checking database values. Each
So these two methods have the same signature but different constraints public static void
Is it possible to have two methods with the same name but different parameters
I'm using the Unity dependency injection framework. I have two classes, that each take
I have an action method that takes in two different objects. I am posting
I have tried different methods and none of them seem to work. When I
Why do we have equals() and equalsIgnoreCase() as two different methods, when equals() could
I have a web app that I'm building. It uses 3 different web services
hei i have a c++03 class with a simple constructor that take an integer.
I have 2 exporter methods (planning to have more) that essentially take my sprite

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.