Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does Fxxx private class name prefix convention came from?

Tags:

delphi

In C++/C# the common convention for private class vars is m_MyPrivateVar, and I belive "m_" stands for "my" (I might be wrong).

In Delphi, private class variables begin with F, e.g. FHandle etc.

What does the F means? Foo? :)

like image 887
Vlad Avatar asked Jan 10 '13 22:01

Vlad


1 Answers

There are some naming conventions not to get lost in code.

Here is an example to point out why this is useful.

// 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; 
like image 90
Sir Rufo Avatar answered Nov 15 '22 23:11

Sir Rufo