Ten Tips Gives your code a Meaningful Names — Clean Code Part 2

1. Use intention-revealing names.

int t; // time in days
int timeInDays;
int timeInMinutes;

2. Avoid disinformation.

ControllerForEfficientHandlingOfStrings //in class and ControllerForEfficientStorageOfStrings //in another class.

3. Make meaningful distinctions.

public static void copyChars(char a1[], char a2[]) {
for (int i = 0; i < a1.length; i++) {
a2[i] = a1[i];
  • word variable should never appear in a variable name.
  • word table should never appear in a table name.
  • variable type shouldn’t be attached to a variable name, Name is better than NameString because name won’t be anything else but text.

4. Use pronounceable names.

class DtaRcrd102 {
private Date genymdhms;
private Date modymdhms;
private final String pszqint = ”102”;
class Customer {
private Date generationTimestamp;
private Date modificationTimestamp;;
private final String recordId = ”102”;

5. Use searchable names.

  • if this number needs to be changed it will be changing in one place only.
  • you can search for it.
  • the shape of all capitals laters makes it easy for your eyes and other developers to find this constant in vary large file code.

6. Avoid Mental Mapping.

7. Class names and Method Names.

string name = employee.getName();
Complex fulcrumPoint = Complex.FromRealNumber(23.0);
Complex fulcrumPoint = new Complex(23.0);

8. Pick one word per concept.

9. solution domain vs problem domain names.

10. Add meaningful context.

  • adding gratuitous context:
  • Member Prefixes:
public class Part {
private String m_dsc; // The textual description
void setName(String name) {
m_dsc = name;
public class Part {
String description;
void setDescription(String description) {
this.description = description;



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store