2013-01-10 20 views
7

C++/C# içinde özel sınıf vars için genel kural m_MyPrivateVar ve "m_" ifadesinin "benim" (yanlış olabilir) anlamına geldiğine inanıyorum.Fxxx özel sınıf adı önek kuralı nedir?

Delphi'de, özel sınıf değişkenleri, F, örn. FHandle vb.

F anlamı nedir? Foo? :)

+9

... alan ..... –

+0

@SertacAkyuz, emin misiniz ??? :) – Vlad

+3

Oh evet o o – whosrdaddy

cevap

17

Kodda kaybolmamak için bazı adlandırma kuralları vardır.

Bunun neden yararlı olduğuna dikkat çekmek için bir örnek.

// 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; 
+1

.Douze noktaları! – Vlad

+16

Parametrelerde "A", "Argüman" dan geldi. –