1

00:00:01,110  -->  00:00:07,290
Let's not look at coding conventions which are essential for writing good clean and professional code

2

00:00:08,280  -->  00:00:14,600
then what on like standard rules defined by experts from their own experience since there are standard

3

00:00:14,610  -->  00:00:20,180
rules if you follow them it would also help your team members in understanding your code.

4

00:00:20,550  -->  00:00:25,490
Even in our project they will follow all the coding conventions that we are going to learn.

5

00:00:25,950  -->  00:00:33,090
It's a very important topic and there are books dedicated to just writing good clean code coding conventions

6

00:00:33,090  -->  00:00:40,530
include several aspects of programming naming classes methods and variables is one of them how to design

7

00:00:40,530  -->  00:00:44,750
our classes and methods is also part of coding conventions.

8

00:00:44,940  -->  00:00:51,630
Similarly conventions also include stylistic aspects like how to indent statements or not and when and

9

00:00:51,630  -->  00:00:53,700
how to write comments.

10

00:00:53,700  -->  00:00:58,790
So let's begin learning about coding conventions by first looking at naming conventions.

11

00:00:58,940  -->  00:01:04,420
Follow up Allisons will include other aspects of coding conventions.

12

00:01:04,470  -->  00:01:10,230
Here is Item five basics for Effective Java which is dedicated to naming conventions and we will look

13

00:01:10,230  -->  00:01:12,170
at most of its suggestions.

14

00:01:12,660  -->  00:01:17,250
It's just sticking to the generally accepted naming conventions.

15

00:01:17,250  -->  00:01:23,160
The item talks about two aspects of naming one is typographical and other is grammatical and we will

16

00:01:23,160  -->  00:01:28,720
look at both of them typographical recommendations are more about appearance.

17

00:01:28,830  -->  00:01:33,010
That is for example what is to use like upper or lower case.

18

00:01:33,390  -->  00:01:40,870
Grammatical recommendations are more about part of speech like usage of verbs nouns and adjectives.

19

00:01:41,850  -->  00:01:47,760
Let's begin with typographical recommendations and let's start with package's just not that there are

20

00:01:47,760  -->  00:01:52,120
no separate grammatical laming recommendations for packages.

21

00:01:52,260  -->  00:01:56,920
However we already looked at this during our discussion on Hultin in packages.

22

00:01:57,240  -->  00:01:59,670
But just quickly glanced through them.

23

00:01:59,670  -->  00:02:04,890
We know that package names include one or more components separated by dots.

24

00:02:04,950  -->  00:02:09,810
The company should use lowercase alphabet characters and rarely digits.

25

00:02:09,930  -->  00:02:15,060
They should generally be shocked that eight of your characters and generally should be single words

26

00:02:16,170  -->  00:02:23,760
meaningful abbreviations are fine and so are acronyms like AWG finally package names should never start

27

00:02:23,760  -->  00:02:29,070
with our job X which are used by standard July API.

28

00:02:29,100  -->  00:02:34,230
Also if your package will be used outside of your organization then you should begin the package Nimrat

29

00:02:34,410  -->  00:02:39,000
your organization's reverse Internet domain name.

30

00:02:39,120  -->  00:02:42,290
Next let's look at classis methods and variables.

31

00:02:42,350  -->  00:02:48,230
We will just look at what we need to use for them classes.

32

00:02:48,300  -->  00:02:53,610
Capitalize the first letter of each word and this also applies to interfaces which will be discussed

33

00:02:53,610  -->  00:02:55,920
later.

34

00:02:55,920  -->  00:03:00,750
For methods and variables used Camelias that is the same as classes.

35

00:03:00,900  -->  00:03:08,320
But the first letter is not capitalized when it comes to topic final variables.

36

00:03:08,320  -->  00:03:14,460
We already discussed that they need to be in all caps with underscores separating words.

37

00:03:14,460  -->  00:03:19,610
Not that this rule does not apply to final instance our final local variables.

38

00:03:20,160  -->  00:03:26,010
No this is a place of variable is primitive but if a variable is an object reference then there is a

39

00:03:26,010  -->  00:03:31,060
certain restriction which is related to a concept that we have not yet discussed.

40

00:03:31,200  -->  00:03:32,630
So I'm not discussing it here.

41

00:03:32,820  -->  00:03:37,440
But you can check out the supplementary notch in the resources section where the restriction is explained

42

00:03:37,450  -->  00:03:38,270
.

43

00:03:39,330  -->  00:03:47,340
Next 100 typographical class is about using abbreviations for classes methods and fields a wide abbreviations

44

00:03:48,730  -->  00:03:51,740
that imply static on instance variables.

45

00:03:51,930  -->  00:03:57,400
You may use abbreviations only for very commonly used names like minimax.

46

00:03:57,590  -->  00:04:05,090
Acronyms are fine for local variables but abbreviations and acronyms are fine.

47

00:04:05,100  -->  00:04:09,860
Individual characters are also fine but only if used in any meaningful way.

48

00:04:09,930  -->  00:04:16,530
For example it is fine if you use X Y and Z for coordinates or I took you pluck off index like in the

49

00:04:16,530  -->  00:04:18,930
case of NRD.

50

00:04:19,200  -->  00:04:21,270
So if you look at typographical aspects.

51

00:04:21,360  -->  00:04:25,860
Now let's look at grammatical aspects of naming for classes.

52

00:04:25,920  -->  00:04:28,650
You're singular No not non-ferrous.

53

00:04:28,650  -->  00:04:32,310
So you use user instead of plural users.

54

00:04:32,310  -->  00:04:37,780
Similarly buffered Roder is a noun phrase and this clause is part of the job package.

55

00:04:38,380  -->  00:04:41,860
Also just try to keep the class names simple and descriptive.

56

00:04:41,970  -->  00:04:49,370
The names should tell us what the class does next let's look at matters from a grammatical standpoint

57

00:04:49,390  -->  00:04:49,520
.

58

00:04:49,610  -->  00:04:54,240
Methods can be named based on what they do or what they're written.

59

00:04:54,710  -->  00:05:02,000
So let's look at the specifics if methods perform some action like appending be a string builder or

60

00:05:02,040  -->  00:05:04,330
calculating distance between two points.

61

00:05:04,580  -->  00:05:10,340
Then you will use a verb or verb phrase as verbs indicate some action.

62

00:05:10,340  -->  00:05:12,840
Also use descriptive names for my goods.

63

00:05:12,920  -->  00:05:18,950
This should tell us what the method does using descriptive names would in fact serve as documentation

64

00:05:18,950  -->  00:05:19,710
too.

65

00:05:20,000  -->  00:05:25,400
That is we do not how to write any additional comments about what the method does.

66

00:05:25,400  -->  00:05:31,550
Also if needed do not hesitate to use longer descriptive names they are better than having shorter ambiguous

67

00:05:31,550  -->  00:05:33,860
ones.

68

00:05:33,890  -->  00:05:38,960
Next is about methods that return a boolean value.

69

00:05:38,960  -->  00:05:45,050
Usually this starts with the key word IIS followed by a noun or noun phrase or an adjective.

70

00:05:45,500  -->  00:05:49,790
One example is a static easy digit method from the character class.

71

00:05:49,880  -->  00:05:52,920
It checks if the input character is a digit or not.

72

00:05:53,540  -->  00:05:59,420
Another example where an adjective is used is the ease implemented from the string class.

73

00:05:59,540  -->  00:06:05,870
It can be invoked on a string object to check whether the string is empty or not when it comes to certain

74

00:06:06,260  -->  00:06:09,410
style matters and the field involves a Boolean field.

75

00:06:09,860  -->  00:06:15,380
Then for setter it would be a set followed by the filename while forgetter it would be East followed

76

00:06:15,380  -->  00:06:16,600
with a feeling.

77

00:06:17,120  -->  00:06:21,770
In this example the field name is active for boolean fields.

78

00:06:21,770  -->  00:06:28,600
Ideas like Eclipse would auto generate getters and setters with such kind of a convention.

79

00:06:28,690  -->  00:06:32,600
We may also sometimes use the E word has instead of ease.

80

00:06:32,790  -->  00:06:39,940
Examples could be has license or has children but has is less frequently used than is.

81

00:06:40,460  -->  00:06:46,480
Next let's see how the name matters that are written in anon boolean attribute of an object.

82

00:06:46,620  -->  00:06:49,780
Here attribute is nothing but an instance variable.

83

00:06:51,080  -->  00:06:54,690
Usually such attributes are known or unknown reasons.

84

00:06:54,770  -->  00:06:58,590
In this case you can simply use the attribute name as a method name.

85

00:06:59,150  -->  00:07:04,280
Alternatively you can also use the word get followed by the attribute name.

86

00:07:04,310  -->  00:07:10,100
You should definitely prefer using the prefix especially if there is a corresponding segment there that

87

00:07:10,100  -->  00:07:12,710
is we are discussing what setters and getters here.

88

00:07:13,100  -->  00:07:18,860
It would be confusing if there is a setter but a set prefix but forgetter we have just the attribute

89

00:07:18,860  -->  00:07:19,930
name.

90

00:07:20,060  -->  00:07:22,750
So if there is a setter use a good person.

91

00:07:22,760  -->  00:07:27,750
Otherwise you may simply use the attribute name as the motard me and it will be very readable in two

92

00:07:28,880  -->  00:07:30,020
separate gap.

93

00:07:30,020  -->  00:07:36,920
If method is performing some action use of a if it is returning a boolean use and is followed by a noun

94

00:07:37,070  -->  00:07:40,270
or adjective or name of the Boolean aggregate.

95

00:07:40,940  -->  00:07:47,240
If it is returning a non boolean attribute of an object then either use attribute name directly or attribute

96

00:07:47,240  -->  00:07:50,280
name that get prefix.

97

00:07:50,430  -->  00:07:52,030
Now before signing off on my text.

98

00:07:52,310  -->  00:07:58,310
Let's also look at one final type of method names that deserves special mention.

99

00:07:58,310  -->  00:08:04,070
There are certain matters that can with the type of an object that is when involved in an object of

100

00:08:04,070  -->  00:08:05,310
a certain type.

101

00:08:05,360  -->  00:08:10,980
There is an independent object of a different type in this because it would use a keyword to.

102

00:08:11,000  -->  00:08:14,140
Followed by the type of the destination object.

103

00:08:14,230  -->  00:08:20,240
Gosling is an example where an independent object of type string is written which would basically be

104

00:08:20,240  -->  00:08:27,810
a string representation of the actual object on which the method was invoked.

105

00:08:27,860  -->  00:08:33,080
Next there are methods whose sole responsibility is to create objects.

106

00:08:33,080  -->  00:08:36,520
These are some commonly used names for such methods.

107

00:08:36,640  -->  00:08:42,400
We have already seen value of method when discussing baulks primitives.

108

00:08:42,590  -->  00:08:49,190
Finally for feels grammatical Conventions are not that bad as stablished and hence are not as important

109

00:08:49,280  -->  00:08:52,940
as for classes on methods for local variables.

110

00:08:53,000  -->  00:09:02,060
Conventions are similar to use but even weaker for boolean fields usually adjectives are used.

111

00:09:02,060  -->  00:09:06,140
Some programmers use a prefix IIS but it is not recommended.

112

00:09:06,140  -->  00:09:14,120
For example use the name actor rather than easier do her nonbelief and feels non-SS unknown phrases

113

00:09:14,120  -->  00:09:17,700
are common for data sources like arrays.

114

00:09:17,870  -->  00:09:26,120
You can use plural nouns for reference to our age and singular norms for its elements.

115

00:09:26,120  -->  00:09:31,410
Finally if you mean how multiple objects of the same class used are the same please.

116

00:09:31,640  -->  00:09:35,750
In this case we should name the object of France by that purpose.

117

00:09:35,750  -->  00:09:41,230
Here is an example of a method in which Blon use it is sending a message to another using.

118

00:09:41,420  -->  00:09:46,750
In this case since both the references are all for user type the first user is named a sender while

119

00:09:46,780  -->  00:09:51,200
the second NESA receiver and that's about naming conventions.

120

00:09:51,500  -->  00:09:57,380
As much as possible you should try to follow these conventions unblinded them only if there is a very

121

00:09:57,380  -->  00:09:58,320
good reason.

122

00:09:59,030  -->  00:10:02,860
So do internalize these conventions and start using them in your code.

123

00:10:03,050  -->  00:10:03,460
Thank you
