Re: Documenting overloaded functions

Subject: Re: Documenting overloaded functions
From: Tom Galloway <tyg -at- panix -dot- com>
To: "TECHWR-L" <techwr-l -at- lists -dot- raycomm -dot- com>
Date: Thu, 24 Apr 2003 13:54:37 -0400 (EDT)


>I've looked at some documentation for .NET classes and it seems like they
>document the overloaded functions separately based on data type, i.e.
>Func(object), Func(char), Func(int).

My take on this is that it depends on the function and why it's overloaded.

For example, let's say you have a diameter() function that takes a single
numeric radius argument. That radius argument could be int, double, long,
etc. And in each case, the function returns the diameter as the same type
as its argument. In that case, it makes sense to group all the doc together,
since the common functionality is the same; just specify what types of
arguments it can take, and that the result will be the same type as the
argument. Example:

diameter(int)
diameter(double)
diameter(long)
Diameter takes a number value of a circle's radius, calculates the
circle's diameter, and returns the diameter value as the same type as
its argument.

Another situation would be if you had a foo() function which could
take arguments a, b, c, etc., where all arguments after a are optional. In
other words, the function is defined for foo(a), foo(a, b), foo(a, b, c).
In this case, again it makes sense to me to document it once, and explain
how the optional arguments affect the function after explaining the core
functionality of foo(a), the required argument. Example:

foo() <general comment>
foo(double a) : a is a required argument for all calls to foo. When only a
is given, foo doubles a and returns it.
foo(double a, boolean b) : When b is true, a's value is doubled,
truncated to 2 digits to the right of the decimal point precision, and
returned. When b is false, a's doubled value is not truncated before
its return.
foo(double a, boolean b, boolean c) : b affects the function as described
above. If c is true, the result display is colored red, if c is false,
the result display is colored blue.

On the other hand, if functionality is substantially different, it'd make
sense to me to break out separate descriptions of each parameter set within
an overall entry of the name of the function. For example:

foo() : <general comment>
foo(int) : doubles the value and returns it.
foo(object) : Extracts the value of object's number field, doubles the value,
sets the object's number field to the doubled value, and
returns the doubled value.

tyg tyg -at- Panix -dot- com

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Last chance to order RoboHelp X3 and receive a $100 mail-in rebate,
PLUS free RoboScreenCapture and WebHelp Merge Module. Offer expires
4/30/03! Order here: http://www.ehelp.com/techwr-l

Help celebrate TECHWR-L's 10th Anniversary starting this month!
Check out the contests at http://www.raycomm.com/techwhirl/special/contests/
Happy birthday to you, happy birthday to you, happy birthday TECHWR-L....

---
You are currently subscribed to techwr-l as:
archive -at- raycomm -dot- com
To unsubscribe send a blank email to leave-techwr-l-obscured -at- lists -dot- raycomm -dot- com
Send administrative questions to ejray -at- raycomm -dot- com -dot- Visit
http://www.raycomm.com/techwhirl/ for more resources and info.



References:
Documenting overloaded functions: From: Rowena Hart

Previous by Author: RE: Software Suggestions
Next by Author: Re: Tech Writer Job Advert (humour)
Previous by Thread: Documenting overloaded functions
Next by Thread: RE: Documenting overloaded functions


What this post helpful? Share it with friends and colleagues:


Sponsored Ads