![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Jun 2006
Location: Ireland
Posts: 152
Rep Power: 3
![]() |
Commenting out parameter names in function parameter list?
Here's an example of some WTL code;
cpp Syntax (Toggle Plain Text)
Notice that the parameter names are commented out. I am sure I came across an explanation of why this is a good thing to do but can't for the life of me remember what it was or where I heard it. Anyone know why this is done and is it good practice? WTL code (from codeproject at least) is full of this.
__________________
Visit my website BinaryNotions. |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
The prototype only requires the types. One wouldn't want to suggest that you have to use specific names, but the commented names are suggestive of the purpose of the argument. It's exemplar. You should use names (despite the fact that they aren't required) that provide useful commentary in your particular application.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 852
Rep Power: 4
![]() |
I think also if you comment out the parameter name, the compiler won't complain that the parameter is unused. In this example, nothing is used, so they are all commented out. Mind you the compiler should still be complaining about not returning a valid return value.
|
|
|
|
|
|
#4 |
|
Programmer
Join Date: Apr 2006
Location: Calgary, Alberta
Posts: 67
Rep Power: 3
![]() |
The parameter is used plenty Dark, it's just that the compiler doesn't care about the name of the variable at that point. You can write:
LRESULT MainDialog::OnInitDialog(UINT, WPARAM ,LPARAM, BOOL&)
{}And the thing will still run fine. The commented out names just suggest the purpose to the programmer before it looks through all the code. When you do the actual function definition, all the variables will still need names so that you can access them. |
|
|
|
|
|
#5 | |
|
Expert Programmer
Join Date: Jun 2005
Posts: 852
Rep Power: 4
![]() |
Quote:
|
|
|
|
|
|
|
#6 | |
|
Hobbyist Programmer
Join Date: Jun 2006
Location: Ireland
Posts: 152
Rep Power: 3
![]() |
Quote:
. Oh and my bad for leaving out the return statement, I was removing the body of the function to avoid confuing things but should have left the return in.Thanks all for your replies.
__________________
Visit my website BinaryNotions. |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| dev c++ software, template problem | cairo | C++ | 11 | Jun 2nd, 2006 12:42 PM |
| libraries | matko | C | 1 | Jan 22nd, 2006 2:12 PM |
| Jackpot game | zorin | Visual Basic | 3 | Jun 10th, 2005 1:19 PM |
| User-defined creatNode and deleteNode functions for a doubly-linked list | jgs | C | 2 | Apr 28th, 2005 8:53 AM |
| airport Log program using 3D linked List : problem reading from file | gemini_shooter | C++ | 0 | Mar 2nd, 2005 4:12 PM |