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

  • Home
  • SEARCH
  • 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 6599595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:30:42+00:00 2026-05-25T18:30:42+00:00

Let’s say I have the following method: public Stream GetMusic(string songTitle, string albumName) {

  • 0

Let’s say I have the following method:

public Stream GetMusic(string songTitle, string albumName) { ... }

A colleague of mine is convinced that this a bad method signature. He would like me to use a Request object, which would transform the method signature into this:

public Stream GetMusic(SongRequest request) { ... }

I really don’t see the point of doing that. The only benefit I see is that it will be easier to add parameters in the future. We won’t have to change the method signature, but the Request object still have to change.

Personally, I don’t think it is a good idea. Using parameters makes it explicit what the method requires to run. In addition, this force us to create another object for not much.

What are the pros and cons of using Request objects? Are you using it in your projects and why?

  • 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-05-25T18:30:43+00:00Added an answer on May 25, 2026 at 6:30 pm

    You are getting data using GetMusic(...) method. If so, it whould probably too much effort to use an additional entity without really need.

    Indeed, in a situation, where is only one input parameter, you can use a custom class. But if that class is the only place to use, so if SongSignature as the class name says, have to be used specifically for this class, that is a bad practice of using “parameter bags”, because it lucks readability.

    Additionally, if someone stupid says that SongSignature must be a structure, and in that structure there is a pointer to some data to be changed inside method, that pointer would never really changes because every time GetMusic is called, it will take a copy of a property bag.

    Even if it is a class, you have to change the accessor for that class to public, and in general this is not the best method to pass an arguments forward to a function and getting results from a function, because you have already getting a stream from that method.

    Let’s assume the following situation:

    If in a team one programmer replaces the parameters with a class SongRequest, second programmer did not find that it is used as a parameter to a functions (because it lucks info in a name of a class), and changed it to a structure on next iteration, third programmer used this method in such a way, that it have to be a class (for example have used class references inside SongRequest)… As a result no one did really knowns why something is not working because each of them have dome right thing… There is no excuse to use a class for a local usage instead of implicit declaration of parameters.

    Generally you have a good chances to get such a situation in a future, because:

    • you are not the one who changes your code (i.e. GetMusic)
    • someone can review the code and find the class ‘SongReqest’ useful (so situation goes even worse – from a local usage to a global usage of a class)
    • adding the SongReuest class can add an additional dependencies for you method (is someone changes this class, most likely you founction will not compile)
    • using SongRequest as a property bag locks it usage only as as a class, as mentioned before.
    • using this class, you method would probably never share it parameters with other function calls (for what reason?)
    • finally, using SongRequest class only for passing parameters for a specific function, gives additional memory overhead footprint, because if this method is called often, at one hand, it will create a lot of unnecessary objects in memory have to be garbage collected, in the other hand, if such a method is used rarely, it will be simply not practical to create a class to pass several variables to a single call

    There is only one real reason to use class instead of a two string arguments: you programmer likes such calls and wants to make all code “more beautiful than before”, more monadic, despite the fact that this is not very practical and useful.

    I would never advice you to make a code looks like this until you want to make it looks better.

    Generally, I suppose that using a custom class for passing an arguments for a function is a bad practice.

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

Sidebar

Related Questions

Let's say you have a class called Customer, which contains the following fields: UserName
Let's say I have the following text: (example) <table> <tr> <td> <span>col1</span> </td> <td>col2</td>
Let's say I have the following object: var VariableName = { firstProperty: 1, secondProperty:
Let's say I have the string: hello world; some random text; foo; How could
Let's say I have the following function in C#: void ProcessResults() { using (FormProgress
Let say I have the following desire, to simplify the IConvertible's to allow me
Let's say I have the following models class Photo(models.Model): tags = models.ManyToManyField(Tag) class Tag(models.Model):
Let's say for example i have URL containing the following percent encoded character :
Let's say we have the following table: CREATE TABLE T ( ID INT, String1
Let's say we have following code: struct A{ virtual ~A(){} void f(){ p =

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.