As said in Uncle Bob's Clean Code, we shouldn't prefix class members. Although I totally agree with the arguments, talking specifically about Delphi, how would we differentiate private fields from public properties?
In Java that's not a problem, since there are no properties.
Microsoft also recommends this practice in big bold letters in their Coding Guidelines. They make the distinction by using lowercase for the private field and uppercase for the public property.
In addition to that, we don't have syntax highlight to field members like other IDEs (Free and Open Source IDEs included...)
So, should we prefix all of our fields? Or just the ones that collide with public properties?
Edit:
I know that the coding standard for Delphi is to prefix the fields with F
, but that's preciselly what was stated as a bad practice in Clean Code. Does it mean that Delphi code cannot be "as clean" as code written in other languages?
The Delphi way is to prefix them with F
:
strict private
FField: Integer;
public
property Field: Integer read FField;
(see the Object Pascal Style Guide.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With