Re: To Hungarian or not to Hungarian



Kevin Frevert wrote:

Is Hungarian notation really dead? What standards do you use?

Yes, it is generally frowned upon these days and has been for a while.

The name should reflect the function or purpose of the item. Also, in
the teams I've lead and participated for quite a long time, the scope
of a variable is seen as the most important "addition" that might be
tacked onto the name. Therefore, we use a single letter prefix that
denotes whether the item is a parameter, a local variable, a global
variable, or a constant. For example,

function GetIDFromName(const pName: string;pIDCandidate: Integer):
Integer;
var
vID: Integer;
vName: string;
begin
vName := UpperCase(pName);
if vName='ABC' then
vID := pIDCandidate
else if vName='DEF' then
vID := gID
else
raise Exception.CreateFmt('GetIDFromName: Unable to obtain ID for
%s,[pName]);
Result := vID;
end;

Admittedly, a somewhat silly example, but I hope you get the idea. This
naming style allows you to create a local vName with the same base name
as the param without having to invent something strange. The similarity
of names stringly suggests the vName value is a local working copy of
the pName value. (BTW, using both allows you to preserve the original
value of pName in case you need it, such as when handling the
exception.)
.



Relevant Pages

  • Query Question
    ... PID | PName ... Vendor ... VID | VName ...
    (microsoft.public.sqlserver.programming)
  • RE: Macro in Excel
    ... Dim vName As String ... Dim vAddress As String ... Dim vRealEstateAgentAndCompany As String ...
    (microsoft.public.excel.misc)
  • RE: Macro in Powerpoint/ced
    ... "John Wilson" wrote: ... Dim vName As String ... Dim vAddress As String ...
    (microsoft.public.powerpoint)
  • RE: Macro in Powerpoint/ced
    ... Dim vName As String ... Dim vAddress As String ... Dim vRealEstateAgentAndCompany As String ...
    (microsoft.public.powerpoint)
  • RE: Macro in excel/ced
    ... Dim vName As String ... Dim vAddress As String ... Dim vRealEstateAgentAndCompany As String ...
    (microsoft.public.excel.misc)