about summary refs log tree commit diff
path: root/usth/ICT2.7/P3L2 A Tale of Analysis and Design Subtitles/3 - Refining Classes and Attributes - lang_en.srt
blob: 271c2fd5cc6b97f29628b27a63ffbfb3253fdf30 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
1
00:00:00,880 --> 00:00:03,920
Okay, so this is our first, class diagram.

2
00:00:03,920 --> 00:00:06,260
>> So, let me ask you something about.

3
00:00:06,260 --> 00:00:06,520
>> Okay.

4
00:00:06,520 --> 00:00:08,930
>> What we've done so far. I also sent, in what

5
00:00:08,930 --> 00:00:14,490
I sent you, I also had some stories about how the actual

6
00:00:14,490 --> 00:00:16,400
>> Library is used. You asked me to do

7
00:00:16,400 --> 00:00:18,950
that and are we going to take, use that here?

8
00:00:20,160 --> 00:00:23,300
>> Glad you asked actually. yeah. Those are, you know, what we call use

9
00:00:23,300 --> 00:00:25,940
cases, or what we will use as scenarios kind of things that we will

10
00:00:25,940 --> 00:00:28,340
use to derive use cases. And they're also a very good

11
00:00:28,340 --> 00:00:31,450
way of extracting requirements. We're not going to look at them right

12
00:00:31,450 --> 00:00:33,890
now because now, because we're more working on kind of the static

13
00:00:33,890 --> 00:00:37,860
structure of the system. But after we're done with the class diagram,

14
00:00:37,860 --> 00:00:40,700
you know, we will do it at a different time. But

15
00:00:40,700 --> 00:00:43,410
we're going to use those to see how the

16
00:00:43,410 --> 00:00:45,850
libraries actually use them, and see whether we can get more

17
00:00:45,850 --> 00:00:49,000
information that we can use to refine our requirements based on that.

18
00:00:49,000 --> 00:00:49,770
>> Okay.

19
00:00:49,770 --> 00:00:51,020
>> Okay,

20
00:00:51,020 --> 00:00:52,940
So, for now, we'll just focus in on the,

21
00:00:52,940 --> 00:00:54,630
structure, but, just so you know, I'm,

22
00:00:54,630 --> 00:00:55,870
I'm glad you sent them, because they were going

23
00:00:55,870 --> 00:00:57,380
very useful as well.

24
00:00:59,410 --> 00:01:00,840
Okay. So let's see. Well, first of all, let

25
00:01:00,840 --> 00:01:03,030
me, seems like that this is already pretty crowded,

26
00:01:03,030 --> 00:01:06,770
right? We have a number of, classes. So let's

27
00:01:06,770 --> 00:01:10,580
see if there's, some class that may be superfluous and

28
00:01:10,580 --> 00:01:13,310
we can model in a different way. So, for

29
00:01:13,310 --> 00:01:16,360
example, you, while, while thinking of this I was thinking,

30
00:01:16,360 --> 00:01:19,450
the library card, it doesn't really contain much

31
00:01:19,450 --> 00:01:22,736
information, right? So is it basically just the number?

32
00:01:22,736 --> 00:01:23,948

33
00:01:23,948 --> 00:01:30,760
The card has a number on it. We have a separate vendor that does that for us so.

34
00:01:30,760 --> 00:01:30,810
>> Oh.

35
00:01:30,810 --> 00:01:33,270
>> We don't need, it doesn't need to be part of this system,

36
00:01:33,270 --> 00:01:35,450
we just have to make sure that every patron has a library card.

37
00:01:35,450 --> 00:01:37,670
>> Okay, so basically for you, in a sense, the library

38
00:01:37,670 --> 00:01:41,560
card is just an ID that gets associated with a patron.

39
00:01:41,560 --> 00:01:42,120
>> That's right.

40
00:01:42,120 --> 00:01:45,380
>> So I think that the best way to represent this, I mean, unless you

41
00:01:45,380 --> 00:01:47,000
need an entity because you are creating it

42
00:01:47,000 --> 00:01:49,160
yourself, but it seems like you are not.

43
00:01:49,160 --> 00:01:52,710
I would just remove this one and I would like to put this,

44
00:01:52,710 --> 00:01:56,020
basically to take the library card number and add it to the pattern.

45
00:01:56,020 --> 00:01:57,100
>> Okay, makes sense.

46
00:01:57,100 --> 00:02:03,000
>> Okay, so I'll add it here. And as

47
00:02:03,000 --> 00:02:06,160
an additional attribute. Okay, and it will eliminate this class.

48
00:02:06,160 --> 00:02:06,410
>> Okay.

49
00:02:06,410 --> 00:02:07,580
>> Okay.

50
00:02:09,690 --> 00:02:11,700
Oh, and, wait a second, so I guess

51
00:02:11,700 --> 00:02:13,940
also the child needs a library card number, right?

52
00:02:13,940 --> 00:02:18,320
>> Child needs a library card number, but let me ask you about that. Is,

53
00:02:18,320 --> 00:02:22,050
is child a separate class, or is it just another kind of patron?

54
00:02:22,050 --> 00:02:24,920
>> Oh, I see, I see. Because, yeah, it

55
00:02:24,920 --> 00:02:28,490
is sort of a special patron, right? And, so

56
00:02:28,490 --> 00:02:31,730
maybe we should, maybe we should represent it as

57
00:02:31,730 --> 00:02:35,640
a kind of a refinement of the patron.

58
00:02:35,640 --> 00:02:38,730
Hm, but then that made me think. So what is

59
00:02:38,730 --> 00:02:42,510
the only thing that characterizes children? Is it just the age?

60
00:02:42,510 --> 00:02:47,440
>> Well, if they're, that they can't check out more than five books.

61
00:02:47,440 --> 00:02:48,890
>> Okay. And the, and the only difference is the

62
00:02:48,890 --> 00:02:52,010
fact that they are less than, you know, twelve years old.

63
00:02:52,010 --> 00:02:52,710
>> Twelve or less, right.

64
00:02:52,710 --> 00:02:56,090
>> Twelve or less. So, I guess, you know, I would probably

65
00:02:56,090 --> 00:03:01,120
like to represent this by making the age explicit in the patron rather

66
00:03:01,120 --> 00:03:04,730
than to represent it as a class. And I'll tell you why,

67
00:03:04,730 --> 00:03:08,300
because one, one of the issues, and you know, that might happen

68
00:03:08,300 --> 00:03:13,070
again, is that, basically, there are patrons that are children. And they're

69
00:03:13,070 --> 00:03:17,130
no longer children, when they come you know 13 or older right.

70
00:03:17,130 --> 00:03:18,100
>> Right.

71
00:03:18,100 --> 00:03:21,990
>> And if we represent them with a separate class in a sense, then we

72
00:03:21,990 --> 00:03:26,620
cannot really change the type of an instance of these classes.

73
00:03:26,620 --> 00:03:28,920
So we're left to kind of destroy the patron, create

74
00:03:28,920 --> 00:03:31,190
a new one, so that means we also have to transfer

75
00:03:31,190 --> 00:03:33,510
any history we want to keep history and so on.

76
00:03:33,510 --> 00:03:35,680
So I, I think I kind of like better the idea

77
00:03:35,680 --> 00:03:39,560
that I represent the age exclusively in

78
00:03:39,560 --> 00:03:42,700
the patron, and then I'll behave differently, based on whether the

79
00:03:42,700 --> 00:03:45,910
patron is 12 years old, or younger, or 13 or,

80
00:03:45,910 --> 00:03:49,600
13 or older. This, do you see any problem with that?

81
00:03:49,600 --> 00:03:51,210
>> It makes things a little simpler.

82
00:03:51,210 --> 00:03:51,490
>> Okay,

83
00:03:51,490 --> 00:03:53,550
and we actually, it allows us also to eliminate

84
00:03:53,550 --> 00:03:56,450
one class here. So I'm going to proceed this way.

85
00:03:56,450 --> 00:03:59,450
I'm going to eliminate the children class, and I'm going to

86
00:03:59,450 --> 00:04:03,600
put the age in the patron. Okay, and let me

87
00:04:03,600 --> 00:04:07,020
see. But in this spirit, actually, something else that jumps

88
00:04:07,020 --> 00:04:09,740
at me is this idea of the bestseller, because I

89
00:04:09,740 --> 00:04:11,850
kind of feel like, we might have the same

90
00:04:11,850 --> 00:04:15,085
problem. So, what is the story? What is a bestseller.

91
00:04:15,085 --> 00:04:16,850
>> Well it's

92
00:04:16,850 --> 00:04:20,750
an item that we want to restrict how

93
00:04:20,750 --> 00:04:23,896
long people can keep, because there is such demand for it.

94
00:04:23,896 --> 00:04:26,880
>> I see, and so basically a book that's a

95
00:04:26,880 --> 00:04:30,450
bestseller, like the New York Times bestseller, is a bestseller forever?

96
00:04:30,450 --> 00:04:32,683
>> No, no, no it's hot for

97
00:04:32,683 --> 00:04:35,940
awhile, and then it becomes just a regular item.

98
00:04:35,940 --> 00:04:38,318
>> I see. Hm. Then I guess it's a

99
00:04:38,318 --> 00:04:40,349
similar situation to the one I was mentioning before, right?

100
00:04:40,349 --> 00:04:40,980
>> Okay.

101
00:04:40,980 --> 00:04:41,800
>> That if we have a book,

102
00:04:41,800 --> 00:04:44,530
it will kind of have to change its type if it becomes a best seller.

103
00:04:44,530 --> 00:04:47,218
Then we have to change its type again, if it's no longer a best seller.

104
00:04:47,218 --> 00:04:47,790
>> Right.

105
00:04:47,790 --> 00:04:48,920
>> So it seems to me that a better

106
00:04:48,920 --> 00:04:52,150
way to represent this, is just to eliminate this BestSeller

107
00:04:52,150 --> 00:04:55,060
class and instead, I'm going to put the best seller

108
00:04:55,060 --> 00:04:58,190
attribute, which would just be a Boolean in the book.

109
00:04:58,190 --> 00:05:00,190
>> Okay, what do you mean by Boolean?

110
00:05:00,190 --> 00:05:02,280
>> Right. We don't know what Boolean is, right? The Boolean is

111
00:05:02,280 --> 00:05:04,940
basically just a number. It can have two values, right? True or false.

112
00:05:04,940 --> 00:05:05,380
>> Okay.

113
00:05:05,380 --> 00:05:06,830
>> So we usually, normally use it

114
00:05:06,830 --> 00:05:09,510
in this in this case. Imagine one, zero,

115
00:05:09,510 --> 00:05:10,970
right? Then it's just kind of the basic.

116
00:05:10,970 --> 00:05:11,120
>> Okay.

117
00:05:11,120 --> 00:05:12,250
>> You know, the bits, right?

118
00:05:12,250 --> 00:05:12,590
>> Okay.

119
00:05:12,590 --> 00:05:14,730
>> So, this is just telling us, it's like a flag

120
00:05:14,730 --> 00:05:16,672
that is telling this book is a best seller, or not.

121
00:05:16,672 --> 00:05:17,053
>> Okay.

122
00:05:17,053 --> 00:05:20,920
>> It's very easy to change this value and make a book a best

123
00:05:20,920 --> 00:05:22,880
seller or not a best seller, than

124
00:05:22,880 --> 00:05:26,210
just creating and destroying instances of these classes.

125
00:05:26,210 --> 00:05:27,135
>> Okay, makes sense.

126
00:05:27,135 --> 00:05:32,630
>> Okay, so at this point, this already looks better, right? Because we have,

127
00:05:32,630 --> 00:05:35,590
less classes, and I think we did, yeah, we

128
00:05:35,590 --> 00:05:38,775
did some serious cleanup. That's good. Okay, so now that

129
00:05:38,775 --> 00:05:40,975
we eliminated some of this, what I would like to

130
00:05:40,975 --> 00:05:42,845
do, as I said, we are going to both clean

131
00:05:42,845 --> 00:05:45,222
up, but also refine. I would like to go

132
00:05:45,222 --> 00:05:48,826
back to our, requirements and see whether we can identify

133
00:05:48,826 --> 00:05:52,566
additional attributes for this, class that maybe are not as

134
00:05:52,566 --> 00:05:55,120
obvious as the one that we saw so far, okay?