Fxxx私有类名称前缀约定来自什么?

Vla*_*lad 8 delphi

在C++/C#中,私有类变量的常见约定是m_MyPrivateVar,我相信" m_ "代表"我的"(我可能错了).

在Delphi中,私有类变量以F开头,例如FHandle等.

F意味着什么?富?:)

Sir*_*ufo 18

有些命名约定不会在代码中丢失.

这是一个例子,指出为什么这是有用的.

// Types begins with T
TFoo = class
strict private
  // sometimes I saw strict private fields beginning with underscore
  // I like this too 
  _Value : string;
private
  // private class vars are Fields and therefore begins with F
  FValue : string;
  function GetValue : string;
public
  property Value : string read GetValue write FValue;

  // Parameters should NOT begin with P (P is for Pointer) but with A
  // because "i will pass A value" :o)
  function GetSomething( const AValue : string ) : string;
end;

function TFoo.GetValue : string;
begin
  Result := '*' + FValue + '*';
end;    

function TFoo.GetSomething( const AValue : string ) : string;
var
  // IMHO there is no naming convention to Local vars
  // but mine begins with L
  LValue : string;
begin

  LValue { local var } := 
    Value   { property via getter }  + 
    AValue  { parameter } + 
    FValue  { field };

  Result := LValue;
end; 
Run Code Online (Sandbox Code Playgroud)

  • 参数中的"A"来自"参数". (18认同)