File Naming Convention.md changed (mode: 100644) (index ffeb332..04d205c) |
35 |
35 |
| Example | FileName01.java | FileName02.java | |
| Example | FileName01.java | FileName02.java | |
36 |
36 |
| ----------- | --------------- | --------------- | |
| ----------- | --------------- | --------------- | |
37 |
37 |
|
|
38 |
|
* Classes and Interfaces Names |
|
|
38 |
|
* *Classes and Interfaces Names* |
39 |
39 |
* Class and interface names are generally noun or noun phrases. |
* Class and interface names are generally noun or noun phrases. |
40 |
40 |
* Class and interface must begin with a capital letter. |
* Class and interface must begin with a capital letter. |
41 |
41 |
|
|
|
45 |
45 |
|Class Example | class FishBowl implements AqueousHabitat { ... } | |
|Class Example | class FishBowl implements AqueousHabitat { ... } | |
46 |
46 |
| -------------------- | ------------------------------------------------ | |
| -------------------- | ------------------------------------------------ | |
47 |
47 |
|
|
48 |
|
* Method Names |
|
|
48 |
|
* *Method Names* |
49 |
49 |
|
|
50 |
50 |
* Method names generally begin with a lowercase letter. |
* Method names generally begin with a lowercase letter. |
51 |
51 |
* A call on a procedure is a statement to do something, so a procedure name is generally a verb phrase that is a command to do something. |
* A call on a procedure is a statement to do something, so a procedure name is generally a verb phrase that is a command to do something. |
|
62 |
62 |
| Example | public boolean isEquilateralTriangle(int b, int c, int d) { ... } | |
| Example | public boolean isEquilateralTriangle(int b, int c, int d) { ... } | |
63 |
63 |
| -------------------- | ------------------------------------------------ | |
| -------------------- | ------------------------------------------------ | |
64 |
64 |
|
|
65 |
|
* Variable Names |
|
|
65 |
|
* *Variable Names* |
66 |
66 |
|
|
67 |
67 |
* Variable names generally start with a lowercase letter. |
* Variable names generally start with a lowercase letter. |
68 |
68 |
* Variable names should give the reader some hint about what the variable is used for. |
* Variable names should give the reader some hint about what the variable is used for. |
|
71 |
71 |
* There is a tension between writing long descriptive names and very short names. |
* There is a tension between writing long descriptive names and very short names. |
72 |
72 |
* We tend to use shorter names for parameters and local variables and longer names for fields and static variables. |
* We tend to use shorter names for parameters and local variables and longer names for fields and static variables. |
73 |
73 |
|
|
74 |
|
* Parameter Names |
|
|
74 |
|
* *Parameter Names* |
75 |
75 |
* Parameter names may be short, even one letter long. |
* Parameter names may be short, even one letter long. |
76 |
76 |
| Example | public boolean isEquilateralTriangle(int b, int c, int d) {return b == c && c == d;} | |
| Example | public boolean isEquilateralTriangle(int b, int c, int d) {return b == c && c == d;} | |
77 |
77 |
| -----------| ------------------------------------------------------------------------------------ | |
| -----------| ------------------------------------------------------------------------------------ | |
78 |
78 |
|
|
79 |
|
* Local variable names. |
|
|
79 |
|
* *Local variable names* |
80 |
80 |
* A local variable is a variable that is declared in a method body. |
* A local variable is a variable that is declared in a method body. |
81 |
81 |
* Its declaration should be placed as close to its first use as possible. |
* Its declaration should be placed as close to its first use as possible. |
82 |
82 |
* The scope of a local variable is usually short, and its meaning is often obvious either from a comment on its declaration or from the short code in which it is used. Therefore, names of local variables may be short. |
* The scope of a local variable is usually short, and its meaning is often obvious either from a comment on its declaration or from the short code in which it is used. Therefore, names of local variables may be short. |
83 |
83 |
|
|
84 |
|
* Fields and class (i.e. static) variables. |
|
|
84 |
|
* *Fields and class (i.e. static) variables* |
85 |
85 |
* The meaning of fields and class variables are typically given as comments by the declarations, far from where the variables are used. |
* The meaning of fields and class variables are typically given as comments by the declarations, far from where the variables are used. |
86 |
86 |
* Therefore, the names of field and class variables should be longer and as mnemonic as possible, giving the reader a good idea what the meaning are. |
* Therefore, the names of field and class variables should be longer and as mnemonic as possible, giving the reader a good idea what the meaning are. |
87 |
|
* Package names |
|
|
87 |
|
* *Package names* |
88 |
88 |
|
|
89 |
89 |
* Package names are usually all lowercase and consist of nouns. |
* Package names are usually all lowercase and consist of nouns. |
90 |
90 |
|
|