4

我正在浏览 Eclipse 插件的源代码(现在我正在探索这个类TextMergeView),我注意到很多变量都被赋予了起始字母f

我知道我们经常给接口加上前缀I,以便第一眼就很容易将它们识别为接口。但可能f意味着什么?

这是一个片段:

......
private int fInheritedDirection;    // inherited direction
    private int fTextDirection;         // requested direction for embedded SourceViewer

    private ActionContributionItem fIgnoreAncestorItem;
    private boolean fHighlightRanges;

    private boolean fShowPseudoConflicts= false;

    private boolean fUseSplines= true;
    private boolean fUseSingleLine= true;
    private boolean fUseResolveUI= true;
    private boolean fHighlightTokenChanges = false;

    private String fSymbolicFontName;

    private ActionContributionItem fNextDiff;   // goto next difference
    private ActionContributionItem fPreviousDiff;   // goto previous difference
    private ActionContributionItem fCopyDiffLeftToRightItem;
    private ActionContributionItem fCopyDiffRightToLeftItem;

    private CompareHandlerService fHandlerService;

    private boolean fSynchronizedScrolling= true;
...

为什么这些变量以 开头f?f 作为前缀是什么意思?

4

1 回答 1

6

它几乎肯定意味着“字段”,但它明显违反了Eclipse 编码约定

私有类变量不能有任何字段前缀或后缀。

class Person
{
    private String name; // NOT private String _name;
    // NOT private String fName;
    // NOT private String name_;
    ...
}

我怀疑这段代码比编码约定更老......

于 2013-05-08T19:45:39.350 回答