English 中文(简体)
“m this”的起源是什么?
原标题:What is the origin of "mThis"?
  • 时间:2011-11-23 08:57:17
  •  标签:
  • android

We have some devs on Android part of our application who actively use prefixing of class member variables with "m*".

“m This”的起源是:

class SomeClass {
    private final SomeClass mThis;
    SomeClass() {
        mthis = this;
    }
}

以及一般的这种说法?

最佳回答
问题回答

我假定,当你需要通过内班提及这一案例时,我就不希望使用“完全合格的”<><>>。 然而,我认为这似乎多余。

本条建议,它源自于微软生态系统的古老习惯特性,但预设的是structs 的成员,其中附有struct的短处。 页: 1 在识别符号all识别符号(包括结构成员姓名)的头八种特性中,只字不提。 简明扼要地确定包含结构的名称是一个便于确保独特名称的机制:

struct inode {
    int number;
    struct device *dev;
}

struct file_descriptor {
    int number;
    struct inode *i;
}

在此情况下,<代码>编号是重复的、非单独和麻烦的。

C的更新版本把struct 姓名贴入其名称空间,从而使这一非议题成为一种非议题,但这一习惯的某些部分已经接过:例如,我们填充的是:

struct iattr {
    unsigned int    ia_valid;
    umode_t     ia_mode;
    uid_t       ia_uid;
....

以及

struct inode {
    /* RCU path lookup touches following: */
    umode_t         i_mode;
    uid_t           i_uid;
    gid_t           i_gid;
    const struct inode_operations   *i_op;
    struct super_block  *i_sb;
...

where the leading ia_ 以及 i_ are from the struct iattr 以及 struct inode -- which makes it slightly easier to read chains like this:

if (!IS_ERR(cookie) && path->dentry->d_inode->i_op->put_link)
    path->dentry->d_inode->i_op->put_link(path->dentry, nd, cookie);

(Really. fs/namei.c, lines 821 以及 822 in my source.)

当你打算使用该成员(该成员很短)的物体变数时,避免发生事故。

private String name;
private String mName;
public void setName(String name) {
    name = name; //wrong, just set the parameter variable to itself
    this.name = name; //ok, but has  this.  which isn t a problem, but some people don t like it
    mName = name; //simples
}

m 成员变量,静态变量。 它是一项共同的命名公约。 但是,像Neutrino一样,我没有使用它。 如果你使用现代的识别和识别系统,则星形色编码给你同样的信息(实际上更多,因为它使原始编码者是否遵循命名公约)。

我使用固定点确定全球类别变量。 我不知道为什么,但当我开始并研究其他roid,情况就是如此。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签