1

00:00:01,020  -->  00:00:04,770
So we implemented a major feature in the last lesson.

2

00:00:04,770  -->  00:00:10,800
No we are going to implement another important feature which is to mark certain bookmarks as kid friendly

3

00:00:10,800  -->  00:00:11,390
.

4

00:00:11,580  -->  00:00:18,180
Nice thing is we already know the feature and the design that goes with it as we were using Treo as

5

00:00:18,180  -->  00:00:22,020
a case study in learning the Object-Oriented concepts.

6

00:00:22,020  -->  00:00:29,700
And just to recap the main idea is to maintain some prefab on the home page just pockets that is under

7

00:00:29,700  -->  00:00:30,760
this new tab.

8

00:00:30,920  -->  00:00:34,580
You will see only bookmarks that are suitable for kids.

9

00:00:34,890  -->  00:00:42,060
The way it works is we have regular bookmarks for all kinds of users but one staff members like editors

10

00:00:42,060  -->  00:00:44,260
and chief editors are using the system.

11

00:00:44,520  -->  00:00:52,110
Then they will see a special link for marking most kinds of bookmarks as kid friendly for certain bookmarks

12

00:00:52,710  -->  00:00:56,110
which are clearly not eligible for kid friendly status.

13

00:00:56,330  -->  00:00:58,760
Some special things will not be displayed.

14

00:00:58,770  -->  00:01:03,600
Examples would include bookmarks falling under categories such as January.

15

00:01:04,020  -->  00:01:09,180
In case you skipped the chapters on object oriented programming then you can check out the first lesson

16

00:01:09,180  -->  00:01:12,830
in the chapter that covers abstract classes and interfaces.

17

00:01:12,870  -->  00:01:14,910
That lesson was this requirement.

18

00:01:15,480  -->  00:01:19,550
But I guess the recap that we just did what most of the requirements.

19

00:01:20,190  -->  00:01:26,340
So it's a nice feature as having a separate tab exclusively for it is very useful.

20

00:01:26,970  -->  00:01:32,730
Now here is a class diagram for implementing this feature and we already implemented this and it is

21

00:01:33,480  -->  00:01:38,940
the missing pieces are the two methods generate profile you are an easy kid friendly eligible.

22

00:01:39,510  -->  00:01:44,880
Let's not worry about Jondrette profile you are for now and let's just implement easy get friendly eligible

23

00:01:44,880  -->  00:01:45,840
method.

24

00:01:46,080  -->  00:01:51,990
Once we implement East get friendly eligible method we will then implement the functionality for marking

25

00:01:51,990  -->  00:01:55,030
bookmarks as kid friendly.

26

00:01:55,110  -->  00:01:59,080
No here is good for any eligibility requirement for movies.

27

00:01:59,370  -->  00:02:05,360
If the movie is either horror or Thriller then the matter to read and falls otherwise it should read

28

00:02:05,360  -->  00:02:06,620
and true.

29

00:02:07,260  -->  00:02:13,420
Similarly for books if the book is either a philosophical or a self-help book then the method Trivett

30

00:02:13,490  -->  00:02:15,010
and falls.

31

00:02:15,510  -->  00:02:18,980
Finally with ramblings The method should read and a false.

32

00:02:19,050  -->  00:02:26,640
If the website is an other site not to implement is good for any eligible method we will follow what

33

00:02:26,640  -->  00:02:31,370
is called s driven development which is in short referred to as P-Diddy.

34

00:02:31,540  -->  00:02:37,200
Best do do double up ment is a software development process where the desk is is written before the

35

00:02:37,200  -->  00:02:40,030
functional code is written for a new feature.

36

00:02:40,230  -->  00:02:45,330
So you don't write the functional code first and then the best guess later you would write the desk

37

00:02:45,330  -->  00:02:46,320
as fast.

38

00:02:46,710  -->  00:02:49,110
And here are the main steps.

39

00:02:49,110  -->  00:02:54,650
So you are right the desk is along with some initial code that would cause the test to fail.

40

00:02:55,230  -->  00:02:59,010
Then you would write enough code to pass the test.

41

00:02:59,040  -->  00:03:00,610
You can repeat this process of.

42

00:03:00,750  -->  00:03:05,010
That's fast approach to incrementally add more functionality.

43

00:03:05,460  -->  00:03:11,880
That is you would add more deaths and then more logic and let us pass.

44

00:03:11,880  -->  00:03:13,530
Here are some real benefits.

45

00:03:13,680  -->  00:03:18,420
And you are already familiar with this slide as it is taken from the eclipse chapter.

46

00:03:18,450  -->  00:03:25,110
When we were discussing about unit tests so we know that such automated does will prevent new code from

47

00:03:25,110  -->  00:03:26,940
breaking the system.

48

00:03:26,940  -->  00:03:34,230
Basically it ensures program correctness at all points of time and that will improve programmer's confidence

49

00:03:34,230  -->  00:03:35,470
.

50

00:03:35,790  -->  00:03:42,510
But one important additional benefit of DDT is that it can also help you in better designing your methods

51

00:03:42,510  -->  00:03:43,440
.

52

00:03:43,440  -->  00:03:50,520
That's because DDT forces you to think through all the scenarios that would cover all the feature requirements

53

00:03:50,520  -->  00:03:51,390
.

54

00:03:51,390  -->  00:03:55,180
So you just tend to have a different thought process when doing.

55

00:03:55,360  -->  00:03:59,340
First approach as opposed to a later approach.

56

00:03:59,370  -->  00:04:06,990
So basically you are driving your design I think as you put it into practice and start using it regularly

57

00:04:06,990  -->  00:04:07,260
.

58

00:04:07,470  -->  00:04:10,380
Then you will be able to better appreciate its approach.

59

00:04:10,800  -->  00:04:15,880
OK that's DDD and let's get started now.

60

00:04:15,930  -->  00:04:22,720
So first thing that we need to do as I'd ease kid friendly eligible matter in the bookmark class.

61

00:04:22,830  -->  00:04:24,960
It really added as an abstract matter.

62

00:04:25,140  -->  00:04:28,290
So let's just go ahead and open the bookmark class.

63

00:04:28,470  -->  00:04:32,720
So there is a shortcut to open a class with this control shift.

64

00:04:32,720  -->  00:04:40,800
Our So this is a shortcut and let's just type and bookmark this right here at the top.

65

00:04:41,640  -->  00:04:43,210
So that's Control shift.

66

00:04:43,590  -->  00:04:45,930
And let's make this abstract.

67

00:04:45,930  -->  00:04:53,520
If you recall this is supposed to be abstract but since we are adding that abstract method only now

68

00:04:53,640  -->  00:05:01,170
so we're making the class abstract now so it will be public

69

00:05:07,120  -->  00:05:12,650
so that's that is kid friendly and vegetable matter and let's just provide the implementation and weblink

70

00:05:13,140  -->  00:05:17,510
selection is going to control shofer are let's do a blank.

71

00:05:17,560  -->  00:05:17,770
OK.

72

00:05:17,770  -->  00:05:20,260
Here it is.

73

00:05:20,360  -->  00:05:22,010
Now we need to implement it.

74

00:05:22,270  -->  00:05:25,530
So that's why it's giving compilation error.

75

00:05:25,690  -->  00:05:29,230
So let's say I unimplemented methods.

76

00:05:30,280  -->  00:05:32,250
So here is the stub.

77

00:05:32,480  -->  00:05:35,740
And let's just return true for now.

78

00:05:35,950  -->  00:05:37,790
Will be clear soon.

79

00:05:37,900  -->  00:05:44,570
Now let's just go ahead and I had a test case for this because we are going to follow the best driven

80

00:05:44,560  -->  00:05:45,600
approach.

81

00:05:45,760  -->  00:05:50,600
So let's just go here and add a new folder called test.

82

00:05:51,680  -->  00:06:03,720
So source folder called best and you might recall it from our G-Unit Allison and Eclipse chapter.

83

00:06:03,760  -->  00:06:11,350
Now within this let's add a package and it has to be the same package as the entities as of eyeblink

84

00:06:11,360  -->  00:06:15,050
because we are going to provide a desk for a web link.

85

00:06:15,270  -->  00:06:15,590
OK.

86

00:06:15,580  -->  00:06:19,500
So the package name will be Chrome

87

00:06:24,550  -->  00:06:25,670
and Cadiz.

88

00:06:25,660  -->  00:06:36,030
Now that's ired a G-Unit desk case since we are testing eyeblink needs to be Rabbe wabbling test.

89

00:06:36,050  -->  00:06:42,320
So that's the convention and we need to load the class which we are going to test.

90

00:06:42,350  -->  00:06:46,400
So it will be Lenk.

91

00:06:47,020  -->  00:06:48,910
So this is the class under test.

92

00:06:49,000  -->  00:06:50,940
And then hit next here.

93

00:06:51,250  -->  00:06:55,790
If you're not providing the class under test then this will not be highlighted here and you'll see only

94

00:06:55,780  -->  00:06:56,610
finish.

95

00:06:56,720  -->  00:07:00,600
So you should select the class under test head next.

96

00:07:00,830  -->  00:07:05,640
And this is the method that we want to test and it says I.

97

00:07:05,690  -->  00:07:13,790
G-Unit library to the barre But let's just say ok and G-Unit has been added here and this is the template

98

00:07:13,880  -->  00:07:15,030
class.

99

00:07:15,130  -->  00:07:15,620
Yes.

100

00:07:15,680  -->  00:07:21,810
If we run this it would fail not to think through our test cases.

101

00:07:21,880  -->  00:07:27,090
So the requirement is that this method is different the eligible should return false.

102

00:07:27,230  -->  00:07:29,050
If it's an adult website.

103

00:07:29,410  -->  00:07:35,080
So let's look at weblink class and see what field it has.

104

00:07:35,090  -->  00:07:41,760
It has a u r l it has a host and if you look at bookmark class it also has a title.

105

00:07:42,290  -->  00:07:43,720
Let's look at all of this here.

106

00:07:43,780  -->  00:07:45,620
So it has a title.

107

00:07:45,640  -->  00:07:47,800
So those are the three fields that we have.

108

00:07:47,810  -->  00:07:53,910
So what we can do is we can look for some keywords in these fields and if the keyword is present we

109

00:07:53,930  -->  00:07:57,180
build it and false otherwise we will return true.

110

00:07:57,190  -->  00:08:03,170
So let's take on our world as the key words are whatever your imagination suggests.

111

00:08:03,520  -->  00:08:05,420
So we can have the logic in this.

112

00:08:05,870  -->  00:08:13,820
If the word porn is present anywhere in the water or in Tipler then we see it and falls Similarly if

113

00:08:13,810  -->  00:08:21,290
the key word either appears anywhere in the hostname then where it involves But if it appears anywhere

114

00:08:21,380  -->  00:08:26,500
else in the order other than the host name then deleted it and true.

115

00:08:26,530  -->  00:08:33,450
Similarly if it if it appears only in title then also it untrue since we are following just doing the

116

00:08:33,450  -->  00:08:39,890
will up meant we will have to frustrate our best guesses and we will then write the actual logic.

117

00:08:39,880  -->  00:08:41,210
So let's do that.

118

00:08:41,840  -->  00:08:47,930
So let's go back into our Webling test and let's write five best cases.

119

00:08:48,280  -->  00:08:49,990
Let's just put some comments first.

120

00:08:50,170  -->  00:08:50,890
Just one

121

00:08:50,890  -->  00:08:59,590
.

122

00:09:00,280  -->  00:09:06,270
So for just one we will test if the key were born as and the you are ill.

123

00:09:06,610  -->  00:09:10,880
In this case it has to return a false.

124

00:09:10,880  -->  00:09:20,260
Next we will check f porn and Titan can never blink instance.

125

00:09:20,670  -->  00:09:24,960
And in this case also the matter has to return false.

126

00:09:25,240  -->  00:09:30,550
You know the third scenario as our gold in Horst.

127

00:09:30,840  -->  00:09:31,120
Right.

128

00:09:31,150  -->  00:09:34,110
So for does it has to return false.

129

00:09:34,230  -->  00:09:44,050
Now our dirt in your order but not in host this hitcher construe

130

00:09:46,900  -->  00:09:53,290
and only in this case also I took control.

131

00:09:53,470  -->  00:09:56,490
So let's just go ahead and build these test cases.

132

00:09:56,590  -->  00:10:02,680
So basically what we are what we have to do is create an instance of a weblink.

133

00:10:02,890  -->  00:10:07,410
And so that would be the book and then we will execute.

134

00:10:07,540  -->  00:10:12,890
We will invoke the east kid friendly eligibility method and then we but it does the output.

135

00:10:13,330  -->  00:10:19,230
So first let's create an instance so that would be the input and we have to create an instance for that

136

00:10:19,250  -->  00:10:27,540
let's just going to data store here because there is already some code for creating an instance you're

137

00:10:27,820  -->  00:10:33,140
just let's use this just won't go back.

138

00:10:33,940  -->  00:10:41,350
No this is a mark of sorted rodent's a weblink.

139

00:10:41,770  -->  00:10:45,690
So Paul and you are of that so let's just go here.

140

00:10:46,120  -->  00:10:47,790
Let's just put it here.

141

00:10:47,890  -->  00:10:51,010
It's on.

142

00:10:51,340  -->  00:10:52,910
So that's the good.

143

00:10:53,230  -->  00:11:01,110
So let's invoke a blank Dorward ease get friendlier richer.

144

00:11:01,130  -->  00:11:04,060
Now this returns a boolean.

145

00:11:04,060  -->  00:11:08,590
So let's assign it to a boolean reliable and that's quite at ease.

146

00:11:08,590  -->  00:11:11,450
Good friendly eligible.

147

00:11:12,620  -->  00:11:15,150
So it has to return a false.

148

00:11:15,400  -->  00:11:25,790
So we will use this method call as Surt falls from the asset class here which is important.

149

00:11:25,900  -->  00:11:27,690
Big group at amateur's.

150

00:11:28,690  -->  00:11:35,980
And the second parameter is the east kid friendly eligible method and if it returns false then we are

151

00:11:35,980  -->  00:11:36,260
good.

152

00:11:36,280  -->  00:11:41,490
But if in case if it returns true then it means that something is wrong.

153

00:11:41,830  -->  00:11:44,860
And then if needed then we need to print a nice message.

154

00:11:45,070  -->  00:11:51,880
So let's just say for porn on some meaningful message and you are still

155

00:11:55,300  -->  00:11:57,350
Maastricht and fonts.

156

00:11:57,860  -->  00:11:58,350
OK.

157

00:11:58,390  -->  00:12:04,100
So let's go ahead and ride the second best.

158

00:12:04,300  -->  00:12:11,030
So if this returns true if this method returns are true for this instance then this message will be

159

00:12:11,040  -->  00:12:11,990
strong.

160

00:12:12,560  -->  00:12:12,900
OK.

161

00:12:12,910  -->  00:12:16,730
So it's right the second best.

162

00:12:17,350  -->  00:12:18,370
Just remove this

163

00:12:21,540  -->  00:12:24,060
and the second just born has to be entitled.

164

00:12:24,070  -->  00:12:27,780
So let's just look at here.

165

00:12:30,040  -->  00:12:34,030
And for on AM.

166

00:12:34,580  -->  00:12:41,500
Is good for and true and it's also remove this here beaming anger.

167

00:12:43,330  -->  00:12:50,290
So now let's copy this whole thing and let's build a third discus.

168

00:12:51,110  -->  00:13:00,680
Now this is about Horst appearing and host sort of just changed this back to.

169

00:13:01,390  -->  00:13:03,720
And here is the host name.

170

00:13:03,850  -->  00:13:05,750
So let's just make it.

171

00:13:06,480  -->  00:13:09,580
I don't want assistance

172

00:13:13,120  -->  00:13:16,560
for I don't.

173

00:13:16,860  -->  00:13:17,640
Host.

174

00:13:17,710  -->  00:13:19,870
He's good for an angiogram was written for.

175

00:13:19,870  -->  00:13:28,280
So this is good for the fourth Test.

176

00:13:28,310  -->  00:13:37,720
Hoes are dead in your world but not in whole Sparta so he can hide it here under knocking holes.

177

00:13:37,720  -->  00:13:40,390
But so this is also good.

178

00:13:40,510  -->  00:13:53,810
So let's just say four hundred in your honor but not host not host vodka for this.

179

00:13:54,280  -->  00:13:55,480
It needs to return it.

180

00:13:55,500  -->  00:13:56,840
True.

181

00:13:57,490  -->  00:13:58,450
What does the matter.

182

00:13:58,450  -->  00:13:59,680
Has it done it true.

183

00:13:59,680  -->  00:14:06,360
Because the term our dirt is not appearing in host it needs to return.

184

00:14:06,370  -->  00:14:06,910
True.

185

00:14:07,180  -->  00:14:12,500
So for truculence concept true if East get friend eligible is assigned true then we are good.

186

00:14:12,550  -->  00:14:18,450
If not it will throw this exception and it will or must return true.

187

00:14:18,470  -->  00:14:21,640
Yeah we need to change this now.

188

00:14:21,670  -->  00:14:24,520
The final test here

189

00:14:28,880  -->  00:14:33,890
just sit in in the title The key word adult should appear in title.

190

00:14:34,790  -->  00:14:35,230
Yeah.

191

00:14:35,270  -->  00:14:39,140
So this is good.

192

00:14:40,050  -->  00:14:45,530
For and Dyken must return true.

193

00:14:45,530  -->  00:14:57,380
So those are all the best guess is that we have now let's just go ahead and run this wabbling best proceed

194

00:14:57,380  -->  00:14:59,010
.

195

00:14:59,970  -->  00:15:05,320
That is in error because we still did not tried the method itself or did not build our logic.

196

00:15:05,750  -->  00:15:10,420
So it says here in the US District has failed.

197

00:15:10,760  -->  00:15:13,500
So let's just go ahead and build our logic now.

198

00:15:13,860  -->  00:15:14,880
Let's go here

199

00:15:18,390  -->  00:15:21,230
on Daines.

200

00:15:23,340  -->  00:15:28,920
So Titlist by free an bookmarks so we cannot access or indirectly.

201

00:15:29,150  -->  00:15:41,450
So we have to use some of this get Teicher we have to use the get method here and to get her.

202

00:15:41,450  -->  00:15:43,490
So let's just go ahead and run this again

203

00:15:43,500  -->  00:15:49,180
.

204

00:15:49,430  -->  00:15:53,720
So now as you can see the first two deaths how free or how fast.

205

00:15:54,050  -->  00:16:01,740
Because we have written the logic for porn but it failed at the third one because at the third one we

206

00:16:01,740  -->  00:16:05,290
are passing our word.

207

00:16:05,450  -->  00:16:09,190
And that is unhorsed and we still do not have the logic for that.

208

00:16:09,260  -->  00:16:13,310
So it's time to write logic for the third one.

209

00:16:14,240  -->  00:16:19,190
So let's just say host Undine's.

210

00:16:19,790  -->  00:16:26,500
So even in this case it has to written as far as if the host has in-groups the key word order.

211

00:16:26,850  -->  00:16:29,820
So let's just go back.

212

00:16:32,370  -->  00:16:41,420
So it passed but it did the fourth one failed for the fourth one we are passing under a new order but

213

00:16:41,420  -->  00:16:44,660
not host part.

214

00:16:47,100  -->  00:16:51,270
Oh I think it's because of this which has to be beaming.

215

00:16:51,780  -->  00:16:53,390
It's just us.

216

00:16:54,080  -->  00:16:54,660
OK.

217

00:16:54,770  -->  00:16:56,120
So that was just an error

218

00:16:56,120  -->  00:17:04,750
.

219

00:17:04,800  -->  00:17:07,860
So now for sure it will work.

220

00:17:08,340  -->  00:17:12,000
So as you can see there are zero errors and zero failures.

221

00:17:12,120  -->  00:17:13,210
So we are good.

222

00:17:13,460  -->  00:17:16,660
So that's how that's one double up and is done.

223

00:17:16,660  -->  00:17:23,360
So we have written the past cases first and then we how bad our logic under that is how passed.

224

00:17:23,580  -->  00:17:24,170
OK.

225

00:17:24,200  -->  00:17:26,110
So that's for eyeblink.

226

00:17:26,150  -->  00:17:28,910
So let's just do four book on movie.

227

00:17:28,970  -->  00:17:34,010
So let me do it offline and then I'll come back and show you the code.

228

00:17:35,420  -->  00:17:35,720
OK.

229

00:17:35,720  -->  00:17:37,210
Here is the more we test.

230

00:17:37,220  -->  00:17:39,900
So that's the best guess for testing.

231

00:17:39,890  -->  00:17:44,180
The movie NDB and here is a method.

232

00:17:44,340  -->  00:17:49,040
So we are testing east kid friendly eligible method and here that here are the two test cases.

233

00:17:49,260  -->  00:17:57,150
So if you recall the condition is that if the movie is either a horror movie or a thriller movie then

234

00:17:57,360  -->  00:17:59,110
the method should read and false.

235

00:17:59,210  -->  00:18:01,700
So that was a condition and that's what we are testing here.

236

00:18:01,730  -->  00:18:08,640
So if that returns false then we are good and we are doing and assert false as we did for the wabbling

237

00:18:08,650  -->  00:18:09,020
.

238

00:18:09,190  -->  00:18:11,200
So so that's those are the two tests.

239

00:18:11,200  -->  00:18:17,320
And let's just go here three and here we are simply checking f genré is a.

240

00:18:17,510  -->  00:18:23,760
Equals equals horror our effort equals thriller than really good return for us which means that it's

241

00:18:23,760  -->  00:18:25,300
not good friendly.

242

00:18:25,490  -->  00:18:34,470
And so this is the book Best And For the book best the condition is that the books should not be either

243

00:18:34,460  -->  00:18:37,490
a philosophy book or self-help book.

244

00:18:37,780  -->  00:18:43,800
OK so once again we are looking at the genre field and we have two test cases for that.

245

00:18:43,800  -->  00:18:49,720
And so if we're going to this method it's very similar to the movie logic.

246

00:18:50,120  -->  00:18:53,330
So that's how you do best Doogan double up.

247

00:18:53,360  -->  00:18:56,440
You write that as Cozzens first and then you die.

248

00:18:56,550  -->  00:19:02,120
And the initial test should fail and then you build the logic and then that well that will pass the

249

00:19:02,120  -->  00:19:02,580
test.

250

00:19:02,630  -->  00:19:03,970
So that's how you would do it.

251

00:19:04,110  -->  00:19:12,620
And if any Duggal a person if they mess up what with the logic here then when the tests are run it is

252

00:19:12,620  -->  00:19:19,110
very likely that they will fail and then they will hold the double up or do fix the issue.

253

00:19:19,350  -->  00:19:20,490
OK.

254

00:19:20,510  -->  00:19:26,300
I also want to say that just go ahead and check out the frequently asked questions and G-Unit site and

255

00:19:26,310  -->  00:19:29,590
they have a real good compilation of frequently asked questions.

256

00:19:30,030  -->  00:19:35,490
So finally I'm also including a few important book references in the resource section and you may want

257

00:19:35,490  -->  00:19:38,790
to buy them at some point if you feel necessary.

258

00:19:39,120  -->  00:19:40,700
And that's about it for now.
