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

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
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Asp.net Important Topics. 0

Top