1
00:00:02,400 --> 00:00:08,160
OK, so the last few videos may have seemed overly complex and confusing, why are we doing all of this

2
00:00:08,160 --> 00:00:10,790
stuff with interfaces and things like that when we really don't need to?

3
00:00:11,610 --> 00:00:16,470
What that leads me to the next topic, which is keep it simple.

4
00:00:16,950 --> 00:00:18,060
It's the kiss pattern.

5
00:00:18,940 --> 00:00:20,460
Good plotless in here.

6
00:00:21,180 --> 00:00:23,400
Keep it simple case.

7
00:00:23,460 --> 00:00:28,380
Now, just because a pattern exists does not mean you need to use it.

8
00:00:29,270 --> 00:00:30,150
I'm going to repeat that.

9
00:00:30,360 --> 00:00:33,020
Just because a pattern exists does not mean you need to use it.

10
00:00:33,480 --> 00:00:38,610
There's a mentality that if a program doesn't use the latest trendy buzzwords, that it's somehow not

11
00:00:38,610 --> 00:00:39,390
a good program.

12
00:00:39,690 --> 00:00:42,370
It's just intrinsically bad and it's not the case.

13
00:00:42,780 --> 00:00:45,210
Simple is always better.

14
00:00:45,210 --> 00:00:50,100
And that is one challenge that I struggle with, because what I'm trying to explain something in a video,

15
00:00:50,100 --> 00:00:54,420
I had to make it overly complex to get the point across and in my brain.

16
00:00:54,420 --> 00:00:56,790
I'm screaming, this should be simpler.

17
00:00:57,300 --> 00:01:00,360
I just get this voice in the back of my head going, Why are you doing this?

18
00:01:00,360 --> 00:01:01,380
This makes no sense.

19
00:01:01,380 --> 00:01:02,220
Stop doing this.

20
00:01:02,640 --> 00:01:06,030
So let's give you an example here, a simple file.

21
00:01:06,040 --> 00:01:12,480
I and I'm going to do what I call junior writing, meaning I'm now a junior developer and I'm going

22
00:01:12,480 --> 00:01:17,340
to come in here and I have taken a design pattern class and I'm going to say, oh, I know Brian makes

23
00:01:17,760 --> 00:01:25,170
these interfaces, so I'm going to make a file I o interface or I file IO and instead of I file it's

24
00:01:25,170 --> 00:01:26,220
I'll file.

25
00:01:26,460 --> 00:01:26,710
Oh.

26
00:01:26,730 --> 00:01:28,140
Just because I want it to be

27
00:01:31,060 --> 00:01:31,860
a Q string.

28
00:01:32,250 --> 00:01:32,550
Yes.

29
00:01:32,790 --> 00:01:37,630
So I'm going to make everybody in the office lives much simpler and I'm going to build this interface.

30
00:01:37,630 --> 00:01:40,920
So as a class I file I o.

31
00:01:43,460 --> 00:01:46,730
Public, and then I want the virtual.

32
00:01:50,690 --> 00:01:51,710
All right.

33
00:01:56,900 --> 00:01:59,710
And yes, so now I need a strong path.

34
00:02:01,860 --> 00:02:03,930
And you string data.

35
00:02:06,350 --> 00:02:06,920
Here we go.

36
00:02:06,950 --> 00:02:12,500
Yes, my masterpiece is almost complete, so we can say virtual string, I'm kind of chuckling as I

37
00:02:12,500 --> 00:02:19,280
do this because I've seen like co-workers and students and previous jobs and classes do this really

38
00:02:19,280 --> 00:02:22,040
just make it as complex as humanly possible.

39
00:02:22,040 --> 00:02:23,840
And there's really no reason for this.

40
00:02:25,190 --> 00:02:30,890
So real short, it's going to read I'm sorry, it's going to write and it's going to read and we're

41
00:02:30,890 --> 00:02:32,870
going to be working with cue strings exclusively.

42
00:02:33,620 --> 00:02:39,380
Now, we've got this interface because, well, I took this class and this class told me I should use

43
00:02:39,380 --> 00:02:42,320
interfaces because I'm following solid.

44
00:02:42,320 --> 00:02:46,220
And then we're going to add new we're going to add this class and we're going to say, OK, let's call

45
00:02:46,220 --> 00:02:50,060
this file system and I'm in the filesystem class.

46
00:02:50,060 --> 00:02:58,010
I'm going to start putting every single file system function that I can possibly think of rename, delete,

47
00:02:58,010 --> 00:02:59,240
read, write, you name it.

48
00:02:59,480 --> 00:03:00,350
It's going to be in here.

49
00:03:00,350 --> 00:03:04,100
This is going to be my kitchen sink for everything file system.

50
00:03:05,450 --> 00:03:09,530
Now, some of you old school programmers are probably cringing right now going, oh, please, no,

51
00:03:09,530 --> 00:03:11,650
don't type all this out and don't worry, I'm not going to.

52
00:03:12,050 --> 00:03:15,320
So we're just going to put a simple example in here so they can file.

53
00:03:16,640 --> 00:03:19,850
And we want to include Q Tech Stream.

54
00:03:23,040 --> 00:03:31,650
And we also want to include our interface cue or I'm sorry, I follow, I follow, I like that word.

55
00:03:32,310 --> 00:03:34,920
And we're going to say public.

56
00:03:37,840 --> 00:03:45,820
I, I oh, and let's go ahead refractor this in oh yes, we are so smart, we got this in here and you

57
00:03:45,820 --> 00:03:46,570
know what we're going to do?

58
00:03:47,080 --> 00:03:53,080
We're going to do an interface for every single thing that we do read, write, rename, delete on it.

59
00:03:53,140 --> 00:04:00,160
So we're going to have about 10000 interfaces and this class is probably going to be about 200000 lines

60
00:04:00,160 --> 00:04:02,590
long and it's going to be just this massive class.

61
00:04:03,520 --> 00:04:04,780
You know, I'm not going to do that.

62
00:04:04,780 --> 00:04:08,500
But just as an example of how crazy I've seen some people take things.

63
00:04:10,210 --> 00:04:14,350
And then I'm going to show everybody this class and tell them how proud I am of it, and then because

64
00:04:14,350 --> 00:04:20,410
they're not doing the same thing, their classes are dumb that I've literally seen people I'm taking

65
00:04:20,410 --> 00:04:23,920
it a bit over the top, but I've literally seen students and co-workers do this.

66
00:04:24,040 --> 00:04:28,390
I mean, when I say co-workers, I was in a company and there was a season program where everybody told

67
00:04:28,390 --> 00:04:29,470
me how smart he was.

68
00:04:29,470 --> 00:04:32,820
And then I sat down with them and he he made something very similar.

69
00:04:32,830 --> 00:04:35,740
And it was just like repetition of what already exists.

70
00:04:35,770 --> 00:04:37,410
So it made no sense.

71
00:04:37,420 --> 00:04:41,500
And I kind of sat him down and said, look, maybe this isn't my place, but there's an easier way.

72
00:04:45,120 --> 00:04:47,580
And anyways, we're going to just take you to extreme.

73
00:04:51,160 --> 00:04:53,380
And we're going to give it our final.

74
00:04:57,020 --> 00:05:01,240
This is where I start making mistakes and I have to pay attention to what I'm typing while I talk,

75
00:05:03,260 --> 00:05:09,530
and then we're going to say file a close notice, multiple issues right up front.

76
00:05:09,710 --> 00:05:11,570
We're just automatically returning.

77
00:05:11,570 --> 00:05:12,080
True.

78
00:05:13,160 --> 00:05:15,740
So we're not monitoring what we actually wrote or anything like that.

79
00:05:16,400 --> 00:05:17,570
We're doing a little bit here.

80
00:05:17,570 --> 00:05:20,030
But really, this is a pretty bad function.

81
00:05:20,030 --> 00:05:20,930
We shouldn't be doing that.

82
00:05:22,700 --> 00:05:24,830
Very much demonstrative purposes only.

83
00:05:29,720 --> 00:05:31,600
And then we're just going to say.

84
00:05:36,430 --> 00:05:41,410
Q String value, it's going to make a blank value that we can return here.

85
00:05:45,970 --> 00:05:48,940
And then we're just going to go back in here.

86
00:05:52,260 --> 00:05:55,050
And because we're reading we want to read only that.

87
00:05:56,790 --> 00:05:59,010
And then we're going to say the value.

88
00:06:06,190 --> 00:06:11,070
And we want to read all on this, so pretty just basic code, to be brutally honest with you.

89
00:06:11,080 --> 00:06:17,950
I mean, it's very rudimentary, but the underlying premise here is that we are breaking the kiss or

90
00:06:17,950 --> 00:06:23,770
the keep it simple design, philosophy or design pattern is that we are overly making this complex.

91
00:06:24,190 --> 00:06:30,760
So what's really going on here is, OK, we have an interface and now we have a file that uses that

92
00:06:30,760 --> 00:06:35,240
interface that's basically doing things that we really don't need to do.

93
00:06:35,960 --> 00:06:36,310
Hmm.

94
00:06:37,760 --> 00:06:40,400
Let's take a look at this and see how we could have done this a little differently here.

95
00:06:40,430 --> 00:06:42,580
So we're going to include some things here.

96
00:06:42,590 --> 00:06:45,840
So we're going to include hyphy.

97
00:06:46,110 --> 00:06:52,040
Oh, and let's go ahead and include the file system, kitchen sink class that we're building.

98
00:06:53,370 --> 00:06:54,950
And then we're going to take you file.

99
00:07:01,590 --> 00:07:05,070
Due to extreme and of course, here, dbag.

100
00:07:08,400 --> 00:07:11,730
All right, so what we're going to do here is we're going to say make some functions and we're going

101
00:07:11,730 --> 00:07:16,740
to do a test I oh, good to just make this completely overly complex here.

102
00:07:21,090 --> 00:07:24,990
I absolutely hate doing this, to be brutally honest with you, my brain right now is screaming, stop,

103
00:07:24,990 --> 00:07:26,490
stop typing, don't do this.

104
00:07:26,490 --> 00:07:27,960
Why are you doing this to me, sir?

105
00:07:28,980 --> 00:07:29,370
All right.

106
00:07:29,370 --> 00:07:33,150
So I keep stirring path.

107
00:07:35,210 --> 00:07:36,320
Provided, costarring.

108
00:07:41,830 --> 00:07:51,070
And then we're going to just say, if I owe that right, I shouldn't say data point or two right path

109
00:07:51,070 --> 00:07:55,270
data, we're just gonna say, are we able to write something?

110
00:07:55,390 --> 00:07:59,760
And then you string value equal.

111
00:08:00,070 --> 00:08:01,330
I read.

112
00:08:02,290 --> 00:08:07,650
And again, we want to just read that same file back, you assert.

113
00:08:07,660 --> 00:08:13,990
So we want to actually just make sure we can actually have the same data back.

114
00:08:18,460 --> 00:08:23,190
I get so used to autocomplete helping me out that when it doesn't, I tend to slow down and go, OK,

115
00:08:23,200 --> 00:08:24,480
did I just break my computer?

116
00:08:24,490 --> 00:08:25,300
What's going on here?

117
00:08:32,660 --> 00:08:39,020
All right, so let's go here, here and let's put in little else, because we live in the real world

118
00:08:39,020 --> 00:08:41,900
where things often do happen and we're so critical.

119
00:08:48,000 --> 00:08:49,170
Well, I really screwed that one up.

120
00:08:49,200 --> 00:08:49,590
There we go.

121
00:08:51,980 --> 00:08:54,350
And we're going to say a complex iota's failed.

122
00:09:02,870 --> 00:09:07,960
So we want to make sure basically that we wrote the data and the data we read back is the same thing.

123
00:09:09,870 --> 00:09:12,150
And then we're going to just say complex.

124
00:09:19,720 --> 00:09:27,580
We could save just a microsecond of typing by doing that, and we're going to say file system and call

125
00:09:27,580 --> 00:09:31,510
us AIFS, our kitchen sink and then we're going to test it.

126
00:09:31,600 --> 00:09:40,600
Oh, we're going to say aifs the path and the data, because as the author of this class, I said,

127
00:09:40,600 --> 00:09:41,770
this is how you should use this.

128
00:09:41,770 --> 00:09:44,440
You shouldn't call this directly, you should blah blah blah blah blah.

129
00:09:45,550 --> 00:09:48,820
Man that gets overly complex and it just makes my brain hurt.

130
00:09:48,820 --> 00:09:52,180
Thinking about how many steps we have to take just to figure out what the heck's going on here.

131
00:09:52,890 --> 00:09:58,540
A friend of mine calls that following the bread crumbs whenever somebody sends him code, says, why

132
00:09:58,540 --> 00:09:59,440
is it my code working?

133
00:09:59,440 --> 00:10:01,210
He calls it, I'm following the bread crumbs.

134
00:10:03,610 --> 00:10:05,050
And then we're just going to say simple.

135
00:10:07,250 --> 00:10:14,090
Have pretty much the same function Prototyp here, and we're just going to do it the simple way, the

136
00:10:14,090 --> 00:10:19,560
way we probably should have done it right from the start, we're just gonna say parve bang.

137
00:10:19,580 --> 00:10:21,530
Now, how is this really different?

138
00:10:23,630 --> 00:10:25,430
Well, we're not making it overly complex.

139
00:10:25,430 --> 00:10:26,300
We're keeping it simple.

140
00:10:26,870 --> 00:10:33,440
And we're going to say open Kuzio device and we're going to do this in a rewrite mode.

141
00:10:38,440 --> 00:10:40,990
And we're going to say, I want to ask you critical.

142
00:10:53,940 --> 00:10:55,140
Simple test failed.

143
00:10:55,170 --> 00:11:00,690
All right, so once we get to this point, what we can do is we can just say, OK, you're too extreme.

144
00:11:00,720 --> 00:11:03,480
We're just gonna keep this as simple as possible here.

145
00:11:03,900 --> 00:11:06,360
There's probably even a way to simplify this further.

146
00:11:10,130 --> 00:11:11,270
And I say stream.

147
00:11:15,500 --> 00:11:22,520
Data, and then we want the stream flush, don't really need that, but I'm ultra paranoid that someone's

148
00:11:22,520 --> 00:11:27,640
going to run this on a different device, like a Raspberry Pi or something, and it didn't, like,

149
00:11:27,710 --> 00:11:29,900
get there in time and then the data is not there.

150
00:11:30,980 --> 00:11:31,400
All right.

151
00:11:31,400 --> 00:11:38,690
So now that we've got all that n q string value, all stream.

152
00:11:51,760 --> 00:11:53,090
Took the air out of there, an accident.

153
00:11:53,110 --> 00:11:53,600
There we go.

154
00:11:53,620 --> 00:11:54,940
So now we got the stream rate.

155
00:11:54,940 --> 00:11:58,750
All we're going to say file closed because we no longer need that.

156
00:11:58,750 --> 00:11:59,820
So we should close it.

157
00:12:00,940 --> 00:12:04,480
And then we're just going to say, you assert.

158
00:12:07,040 --> 00:12:10,070
And we want to say our value because the data.

159
00:12:20,480 --> 00:12:25,160
Simple test passed, and I'm almost embarrassed making this overly complex, because let's be honest

160
00:12:25,160 --> 00:12:27,390
here, there's no need for any of this stuff up here.

161
00:12:28,250 --> 00:12:28,670
All right.

162
00:12:28,670 --> 00:12:32,630
So now that we've got that in, we got my notes in.

163
00:12:32,840 --> 00:12:36,290
Let's go ahead and make the magic happen, as we say.

164
00:12:39,090 --> 00:12:44,490
All right, so we can say a Q string path equals and I'm just going to do it in the same directories

165
00:12:44,490 --> 00:12:45,210
are executable.

166
00:12:51,670 --> 00:12:52,810
And we want data.

167
00:12:55,370 --> 00:12:56,890
Hello, world.

168
00:12:56,910 --> 00:12:57,550
Why not?

169
00:12:59,290 --> 00:13:04,240
And then we're going to call complex and we want to say path and data.

170
00:13:07,610 --> 00:13:13,310
And then we're going to call our simple and let's call this path and data.

171
00:13:13,560 --> 00:13:14,150
There we go.

172
00:13:17,610 --> 00:13:24,650
And I'm going to come at this out for now, say Seyran should work complex iota's past.

173
00:13:25,710 --> 00:13:27,360
All right, but what if it didn't?

174
00:13:27,870 --> 00:13:31,010
We would have to go to this function here.

175
00:13:31,710 --> 00:13:35,960
Oh, now we're making a class, but we're passing this class of this function.

176
00:13:36,020 --> 00:13:37,320
Now we got to look at this function.

177
00:13:38,040 --> 00:13:38,520
All right.

178
00:13:38,550 --> 00:13:40,650
So now we've got a pointer and a path and blah, blah, blah, blah.

179
00:13:40,680 --> 00:13:42,830
Well, now what are we doing with this area?

180
00:13:42,880 --> 00:13:44,430
So now we've got to go into this class.

181
00:13:44,430 --> 00:13:48,020
And first thing I see, well, we're using an interface.

182
00:13:48,030 --> 00:13:49,050
So what's the interface?

183
00:13:49,050 --> 00:13:49,950
And you get the point.

184
00:13:49,950 --> 00:13:55,120
You've got to jump all over the place just to figure out what the heck we're actually doing.

185
00:13:55,140 --> 00:13:58,710
So if whomever is making this kitchen sink class.

186
00:13:59,940 --> 00:14:01,170
Does something here.

187
00:14:06,150 --> 00:14:09,240
Everything that uses this class now breaks along with it.

188
00:14:10,810 --> 00:14:17,500
There's a much simpler way follow, you guessed it, the kiss design pattern, which is just keep it

189
00:14:17,500 --> 00:14:18,040
simple.

190
00:14:18,820 --> 00:14:21,100
All of that fits very nicely in one function.

191
00:14:21,100 --> 00:14:25,680
And I dare say you could probably even simplify this function even further down to a few lines.

192
00:14:26,080 --> 00:14:27,520
It's very, very simple.

193
00:14:27,520 --> 00:14:30,280
There's no reason to make this overly complex.

