basic: should you reassign parameters, or use them without renaming/reassigning?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This is a very basic question about programming convention and best
practice.

Methods often take parameters, and in C# the datatypes and parameter names
are declared in the method signature:
public void CreateNewsletter (int pubVol, int pubNo, string title, DateTime
pubDate)

Should these parameters subsequently be assigned to differently-named
variables in the body of the method, or should they be used directly
as-named in the method signature?

Is there a consensus on this point? It seems like re-assigning them might
be more "tidy," at the cost of more chance of breakage if names are changed
later.

-KF
 
KF,

I don't see why they should be reassigned. If anything, it's overhead
to perform the assignment (not anything to write home about, but its there).

Also, if your parameter names on your publicly exposed methods are
changed, you have bigger concerns than the implementation of that method
(change of this kind indicates a design change/bad design, and bad design is
always a bigger PITA than bad implementation).

Hope this helps.
 
Back
Top