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 7930475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:26:14+00:00 2026-06-03T20:26:14+00:00

In a code review a co-worker changed my code to pass in a Stream

  • 0

In a code review a co-worker changed my code to pass in a Stream as a parameter. He said this was to ensure that the responsibility to dispose of the object is clear to the caller. In a sense I can empathize. I would prefer the object creator to also be responsible for cleanup.

On the other other hand, neither method makes the need for a using any more clear. I prefer the simpler method call as well.

Take

    public static TextReader Serialize<T>(T obj) where T: new()
    {
        if (obj == null) throw new ArgumentNullException("obj");
        return Serialize<T>(obj, null);
    }

VS

    public static void Serialize<T>(T obj, TextWriter outbound) where T : new()
    {
        if (obj == null) throw new ArgumentNullException("obj");
        Serialize<T>(obj, outbound, null);
    }

Is there any technical reason to add the extra param?

  • 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-03T20:26:15+00:00Added an answer on June 3, 2026 at 8:26 pm

    It strictly depends on your code architecture.

    I, personally, like the second approach (even if it adds one more argument) where definition of the function states that it will not close/dispose a stream, but it’s up to the Caller.

    This is very useful in case when you’re going to call the same functions on the same stream, cause if you imagine, that every function call will close and reopen the stream, it becomes resource consuming operation.

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

Sidebar

Related Questions

I'm doing code review and came across a class that uses all static methods.
This is a code review question more then anything. I have the following problem:
During a code review I presented a method quickly to the team that I
During a code review I've come across some code that defines a simple structure
Doing a code review I've stumbled over GWM in Java-Spring-GWT web-application. As this product
This came up as one of the code review comments. Is it a good
A co worker of mine asked me to review some of my code and
During code review I discovered many places of our C# code that looks like
The code works but looks messy so this might be a code review question
In a recent code review, a contributor is trying to enforce that all NULL

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.