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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:55:40+00:00 2026-05-28T16:55:40+00:00

When the purpose of a method is to calculate a value and return it,

  • 0

When the purpose of a method is to calculate a value and return it, I find myself documenting it as follows:

/// <summary>
/// Calculates the widget count.
/// </summary>
/// <param name="control">The control to calculate the widget count of.</param>
/// <returns>The widget count.</returns>

Here the returns tag does not provide any new information: it’s just repeating what’s in the summary. (The exception is methods that return bool, where it’s easy to explain what the true and false return values mean.)

Am I missing something? Is there a standard way of wording XML documentation blocks to avoid repetition between the summary and returns tags?

  • 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-28T16:55:42+00:00Added an answer on May 28, 2026 at 4:55 pm

    Sometimes documentation does tend to repeat itself, especially with Properties (to an external caller they should look and feel just like simple values, so it is hard to see any point in providing both ‘summary’ and ‘value’ entries).

    So I try to draw a distinction between the summary and param/returns/value etc that reduces the repetitiveness. The summary briefly describes what the method does (calculate the widget count), while the param/returns/value give detail of the inputs/outputs (and nothing else). In many cases you then see a more marked difference between the entries – reading your example, I immediately have questions about the API that the documentation doesn’t answer, so I’d be hoping to see something more like one of these alternatives:

    /// <summary>Recursively calculates the widget count for a given control.</summary> 
    ///
    /// <param name="control">The root control of the subtree to process, or null.</param> 
    ///
    /// <returns>
    /// The number of widgets that are contained within 'control' and its
    /// entire subtree of descendant controls (or 0 if control is null).
    /// </returns>
    

    or…

    /// <summary>Calculates the widget count for a given control.</summary> 
    ///
    /// <param name="control">The control to process. May be null.</param> 
    ///
    /// <returns>
    /// The number of widgets that are direct children of 'control', or
    /// -1 if it is null/not a registered control.
    /// </returns>
    

    or even …

    /// <summary>
    /// Calculates the widget 'count' for a given control using the
    /// Wicker-Bartland meanest minimum average algorithm.
    /// </summary>
    ///
    /// <param name="control">
    /// The Wicker-Bartland control-input-value, in the range 1.0 .. 42.6
    /// </param> 
    ///
    /// <returns>
    /// The widget count, in the range -2PI .. +2PI, or Double.NaN if the
    /// input control value is out of range.
    /// </returns>
    

    Unlike what @Bertie seems to be suggesting, I always try to reduce the verbosity and increase the information content – As you know what the method does, you may not need so much detail in the parameter description to describe what it is for, as it’s often pretty obvious/intuitive – but you will often be able to add more detail about what values are legal or how the parameter is used, to help the reader understand how best to use it. Similarly for detail about what kind of return value I will get (e.g. whether I might get back zero, negative values, nulls, etc)

    Think of this documentation as defining the code contract – the more explicitly you state the contract, the less ambiguous it becomes and the more easily another programmer will be able to work out how they can (and cannot) use your method without having to read the source code. Or identify if the behaviour of your method is as intended or a bug. Or know how much they can alter the behaviour of your method without breaking any of the existing calling code.

    Of course, in some cases a method really is simple and obvious enough that you can just comment it with AtomineerUtils and move on, saving time for more important work. Often programming needs to be a balance between being practical (get the work done and the product shipped) and meeting theoretical ideals (DRY, etc).

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

Sidebar

Related Questions

Purpose: Obtain the public method signature(return value,parameter,method name) from java bytecode files. I am
I have a method which purpose is to receive an image and return it
I've got a method in my class only for testing purpose : private void
I'm a little confused as to the purpose of the ExpectConstructor() method on the
I'm trying to create an Extension Method for MVC's htmlHelper. The purpose is to
In .NET Remoting, Activator.GetObject method has a state parameter. What is the purpose of
The purpose of my method is to get the currentTime, and set it back
Consider an extension method whose purpose is to either: render an <a> tag on
Is there a better way to refactor the following method which's purpose is to
Main purpose of this task is to calculate volumes and surface areas of three

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.