1 00:00:00,000 --> 00:00:02,410 [No Audio] 2 00:00:02,410 --> 00:00:05,043 At this point. As a general point, it kind of feels 3 00:00:05,043 --> 00:00:07,786 a bit dirty that we just copied and pasted that method. 4 00:00:07,786 --> 00:00:09,968 So don't do that. Instead, 5 00:00:09,968 --> 00:00:13,445 what I would do is I'd basically take this, 6 00:00:13,445 --> 00:00:14,995 create another method 7 00:00:14,995 --> 00:00:17,730 [No Audio] 8 00:00:17,730 --> 00:00:19,013 and say call this, 9 00:00:19,013 --> 00:00:21,046 [No Audio] 10 00:00:21,046 --> 00:00:26,341 getUsersByUserTypes, user type 11 00:00:26,341 --> 00:00:28,691 I’ll probably make this private 12 00:00:28,691 --> 00:00:31,124 [No Audio] 13 00:00:31,124 --> 00:00:33,040 and pass in UserType 14 00:00:33,040 --> 00:00:35,552 [No Audio] 15 00:00:35,552 --> 00:00:37,680 enum, just import 16 00:00:37,680 --> 00:00:40,080 that and then I would use that here. 17 00:00:40,080 --> 00:00:43,339 [No Audio] 18 00:00:43,339 --> 00:00:45,112 And in doing so we can replace them, 19 00:00:45,112 --> 00:00:47,092 these implementations, I can just replace these 20 00:00:47,092 --> 00:00:48,872 now we've returned 21 00:00:48,872 --> 00:00:51,099 this more generic method, 22 00:00:51,099 --> 00:00:57,088 getUsersByUserType(User.UserType.ADMIN_USER 23 00:00:57,088 --> 00:00:59,560 and similarly I could do the same thing here. 24 00:00:59,560 --> 00:01:02,990 [No Audio] 25 00:01:02,990 --> 00:01:05,215 Type.REGULAR_USER. That's good. 26 00:01:05,215 --> 00:01:06,866 I don't feel as dirty now. 27 00:01:06,866 --> 00:01:07,978 Everything's dry. 28 00:01:07,978 --> 00:01:09,382 They don't repeat yourself principle. 29 00:01:09,382 --> 00:01:12,815 Do not have duplicate curve blocks that's much nicer. 30 00:01:12,815 --> 00:01:15,730 Control Alt R to tidy up any imports 31 00:01:15,730 --> 00:01:17,071 if we need to, which we don't. But it's 32 00:01:17,071 --> 00:01:18,884 a nice thing to just get into the habit of doing it. 33 00:01:18,884 --> 00:01:21,172 Makes things neater and tidier as we go along. 34 00:01:21,172 --> 00:01:23,806 But anyway, now we've kept things nice and dry. 35 00:01:23,806 --> 00:01:25,498 That's the don't repeat yourself principle, 36 00:01:25,498 --> 00:01:26,864 where we're not repeating code or 37 00:01:26,864 --> 00:01:28,712 just mindlessly copying pasting code. 38 00:01:28,712 --> 00:01:30,536 And we've made it now such that we have 39 00:01:30,536 --> 00:01:32,914 a parameter driven method which is much nicer. 40 00:01:32,914 --> 00:01:34,336 So let's move on.