Passing variables between functions - naming conventions

doddwell
Member Posts: 65
Hello
This is a generic (probably picky!) question about the recommended naming conventions when passing variables between functions.
I have a form that calls FunctionA in a codeunit. FunctionA expects the parameter custNumber.
FunctionA calls FunctionB. FunctionB expects the parameter custNumber.
Should the parameters in both functions have the same name (custNumber) as per my example above? Or would you expect them to be different?
Thanks very much.
This is a generic (probably picky!) question about the recommended naming conventions when passing variables between functions.
I have a form that calls FunctionA in a codeunit. FunctionA expects the parameter custNumber.
FunctionA calls FunctionB. FunctionB expects the parameter custNumber.
Should the parameters in both functions have the same name (custNumber) as per my example above? Or would you expect them to be different?
Thanks very much.
0
Comments
-
[Disclaimer: this is my view only and must not be regarded as authoritative]
It's OK to name parameters to different functions the same. Standard NAV code does it all the time and there is little reason to transmogrify the names of parameters just to be different, especially if they are essentially the same, only in a different location.
According to the style guide, the variable name should start with a capital letter, though.
Function parameters and local variables should not be named the same as some global object. Even when the compiler is able to tell them apart, a human being might get confused or misled.0 -
Thanks Vaprog.
I have been defining my variables with a leading Lower case letter (and my functions with a leading upper case letter). You are correct though (as per http://download.microsoft.com/download/8/D/F/8DF0E4EB-A660-4D64-A44B-0D15D579073A/NAV%20CAL%20Programming%20Guide.pdf), page 41.0 -
Hi Doddwell
Not following any Microsoft convention but we use 'l' for local variables, 'g' for global variables and 'p' for parameter variables, i.e.,
Calling Function B
FunctionB (lCustNumber);
Function B
FunctionB (pCustNumber)
Good luckBig D signing off!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions