1
00:00:01,500 --> 00:00:07,950
One of the things that I try to do on a regular basis is to go through my code regularly as I'm working

2
00:00:07,950 --> 00:00:10,730
on a project and just do a code review.

3
00:00:11,250 --> 00:00:16,020
And in the best of all possible worlds, code reviews are done by somebody else.

4
00:00:16,020 --> 00:00:16,940
I'll write code.

5
00:00:16,950 --> 00:00:20,720
Somebody else will review it and we'll make changes as necessary.

6
00:00:21,240 --> 00:00:26,220
But when I'm working by myself, which I do a great deal of the time, I wind up doing the code review

7
00:00:26,220 --> 00:00:26,850
on my own.

8
00:00:27,000 --> 00:00:32,610
And I typically set aside Wednesday afternoons to go through the previous weeks work and just find things

9
00:00:32,610 --> 00:00:33,600
that need to be cleaned up.

10
00:00:33,990 --> 00:00:37,810
And if you look at our code base right now, there are a few things that need to be cleaned up.

11
00:00:37,860 --> 00:00:46,020
For example, I have this reservation model which we were using early on, but I also have this reservations

12
00:00:46,020 --> 00:00:48,880
model, plural, and they duplicate each other.

13
00:00:49,080 --> 00:00:55,070
I don't need this one anymore, so I'm going to get rid of it, which means that a few things will break.

14
00:00:55,440 --> 00:01:01,500
For example, in the main package, I no longer can put a reservation model in there because it doesn't

15
00:01:01,500 --> 00:01:02,200
exist anymore.

16
00:01:02,220 --> 00:01:05,130
I'm going to leave that alone for a minute because there's another thing that I noticed.

17
00:01:05,970 --> 00:01:15,330
I've named every one of these types using a plural word, even though in code, when I draw a particular

18
00:01:15,330 --> 00:01:18,480
user out of the database, I'm looking at one user.

19
00:01:18,810 --> 00:01:23,400
When I want to have more than one users, I'll draw a slice of users out of the database.

20
00:01:23,850 --> 00:01:30,600
So I'm going to rename this model to User and I'll rename the comment and I'll do that for all of my

21
00:01:30,600 --> 00:01:33,870
models because they all should be singular.

22
00:01:33,870 --> 00:01:40,110
It just makes your code read better when you have the S on the end making user, for example, plural

23
00:01:40,110 --> 00:01:40,770
users.

24
00:01:41,160 --> 00:01:47,250
Your code really isn't as readable because it implies there might be more than one in that when in fact

25
00:01:47,370 --> 00:01:48,050
there is not.

26
00:01:48,900 --> 00:01:50,280
So let's fix all of these.

27
00:01:53,270 --> 00:01:54,650
And let's fix these two.

28
00:01:57,830 --> 00:02:00,280
So that should take care of it here.

29
00:02:01,170 --> 00:02:03,860
Now, back in our main, did that fix this problem?

30
00:02:03,890 --> 00:02:04,670
Yes, it did.

31
00:02:04,790 --> 00:02:07,060
What else might I store in the session?

32
00:02:07,070 --> 00:02:14,570
I may as well as I'll put in my user and I may as well put in a room, and I may as well put in a what

33
00:02:14,570 --> 00:02:15,470
else do we have in here?

34
00:02:16,040 --> 00:02:17,110
Room restriction.

35
00:02:17,130 --> 00:02:17,450
Sure.

36
00:02:17,480 --> 00:02:18,760
Let's put in a restriction, too.

37
00:02:18,800 --> 00:02:24,940
We may not use it, but it's not going to hurt anything at all to register these in the session.

38
00:02:24,950 --> 00:02:27,120
So there's there's a couple of things clean up right away.

39
00:02:27,530 --> 00:02:30,170
Now let's check our handlers and make sure they didn't break.

40
00:02:32,630 --> 00:02:36,380
No, no errors, they're good so far, so good, and let's make sure it runs.

41
00:02:40,520 --> 00:02:44,210
Everything piles, that's good, and let's try our tests.

42
00:02:49,610 --> 00:02:56,780
And we have a break, so main test go assignment mismatch one variable, but one returns to values a

43
00:02:56,780 --> 00:02:57,040
aha.

44
00:02:57,050 --> 00:02:58,010
Let's go fix that.

45
00:02:58,400 --> 00:02:59,480
So that's in main test.

46
00:02:59,480 --> 00:03:01,760
Go and run now.

47
00:03:01,760 --> 00:03:03,450
Actually takes two variables.

48
00:03:03,470 --> 00:03:12,350
So the first one we'll just ignore and for this one, not enough arguments to call in call to new repo.

49
00:03:13,310 --> 00:03:13,850
Right.

50
00:03:13,880 --> 00:03:17,810
Because here we actually need to pass a database connection.

51
00:03:17,810 --> 00:03:18,290
Cool to it.

52
00:03:18,530 --> 00:03:24,680
I'm going to leave that alone right now because what we're going to do is use our repository repository

53
00:03:24,680 --> 00:03:28,520
model to create a test database repository.

54
00:03:28,520 --> 00:03:29,690
And we're not going to do that right now.

55
00:03:29,720 --> 00:03:31,010
We'll do that in a future lecture.

56
00:03:31,010 --> 00:03:32,670
So I'll leave that one alone for right now.

57
00:03:33,530 --> 00:03:36,170
Now, is there anything else that makes no sense?

58
00:03:36,330 --> 00:03:39,680
Or I noticed one other thing when I went through my code, and you may have noticed it, too.

59
00:03:40,290 --> 00:03:43,850
I'm down here at the end of the run function in May not go.

60
00:03:44,330 --> 00:03:46,180
I'm calling Handler's new handler.

61
00:03:46,190 --> 00:03:46,820
That's fine.

62
00:03:47,030 --> 00:03:49,310
And I'm calling render new templates.

63
00:03:49,520 --> 00:03:53,630
But new templates is actually a package call in a package called Render.

64
00:03:53,930 --> 00:03:55,810
So I'm going to rename that that method.

65
00:03:56,390 --> 00:04:03,080
So instead of calling it new templates, I'll call it New Renderer Earth and then I'll fix the comment.

66
00:04:04,670 --> 00:04:09,410
And down here in this package, I have the function named render template.

67
00:04:09,530 --> 00:04:17,930
Instead, let's just call it template because it's convention not to name a function in a given package

68
00:04:18,080 --> 00:04:20,930
with the name of the package as the first part of the word.

69
00:04:21,200 --> 00:04:23,090
It just makes it more readable.

70
00:04:23,690 --> 00:04:26,100
So we'll have to fix things in our main function here.

71
00:04:26,630 --> 00:04:34,250
This will be new renderer and then we'll have to fix things renderer and then we'll have to fix things

72
00:04:34,250 --> 00:04:35,870
that our handlers, because those are broken now.

73
00:04:36,890 --> 00:04:42,020
Everywhere I called render template is, should you say, render dot template, which actually reads

74
00:04:42,020 --> 00:04:42,560
much better.

75
00:04:42,590 --> 00:04:48,950
So what I'll do is copy this and say edit find and replace.

76
00:04:52,460 --> 00:05:00,500
So I'll find Renderer, render template and replace it with Renderer, render dot template, and that

77
00:05:00,500 --> 00:05:01,010
should fix it.

78
00:05:02,760 --> 00:05:07,620
And it appears to let's make sure things run out, clear the screen.

79
00:05:13,000 --> 00:05:13,960
That's much cleaner.

80
00:05:14,170 --> 00:05:19,690
OK, so that was just a minor cleanup and we do have to remember that we're going to have to fix our

81
00:05:19,690 --> 00:05:24,570
set up tax test here so we can fix this one right now, render new renderer.

82
00:05:25,270 --> 00:05:30,310
We'll have to fix this part and we'll do that when we get to when we actually have a couple of database

83
00:05:30,310 --> 00:05:31,300
functions to test.

84
00:05:31,300 --> 00:05:38,140
Will set up a new repo repository database repository specifically for testing.

85
00:05:38,590 --> 00:05:43,410
And we'll use that in this this test, but will be a couple of lectures before we get there.

86
00:05:43,780 --> 00:05:46,530
In the meantime, we have cleaned up our our code a little bit.

87
00:05:46,540 --> 00:05:47,680
We've made it more readable.

88
00:05:47,920 --> 00:05:51,820
And I think that we are ready to move on to actually work with the database.

89
00:05:51,950 --> 00:05:53,320
So let's do that in the next lecture.
