Difference between revisions of "Don't Use Member Prefixes"

From Basef
Jump to: navigation, search
(Criou página com 'You also don’t need to prefix member variables with m_ anymore. Your classes and functions should be small enough that you don’t need them. And you should be using an edit...')
 
 
Line 6: Line 6:
 
     private String m_dsc; // The textual description
 
     private String m_dsc; // The textual description
 
     void setName(String name) {
 
     void setName(String name) {
            m_dsc = name;
+
        m_dsc = name;
 
     }
 
     }
 
}
 
}

Latest revision as of 12:17, 27 January 2020

You also don’t need to prefix member variables with m_ anymore. Your classes and functions should be small enough that you don’t need them. And you should be using an editing environment that highlights or colorizes members to make them distinct.

No:

public class Part {
    private String m_dsc; // The textual description
    void setName(String name) {
        m_dsc = name;
    }
}

Ok:

public class Part {
    String description;
    void setDescription(String description) {
        this.description = description;
    }
}

Source: Clean Code