Let's get started with our project implementation we'll begin with creating entities which correspond 2
to database tables. 3
Let's create a new project that's named after leo. 4
So we have two projects now one is for the demo and the other is for the real project which is trillion 5
. 6
Now let's just go ahead and create a new package 7
. 8
So it's called camarade semantics squared are truly ordered entities and we will have all our entities 9
within this package. 10
So let's create the user entity so that the user class. 11
So just going to new 12
Unix are some instance variables. 13
First is the ID field. 14
I will soon explain why Id feel has this type long instead of. 15
And let's add all other variables. 16
Last word 17
last name. 18
Last name. 19
Let's have gender roles in. 20
It's also include a user type. 21
So this is like a screen and we will also discuss it and embed. 22
So we how all these instance variables to begin with. 23
So let's just go ahead and create getters and setters. 24
So let's just go here and do source and it's just our bhajan read them. 25
So that's how you come here and select all. 26
And let's head. 27
OK. 28
Now we how all our getters and setters let's just do a control shift. 29
Just to make sure that everything is formatted right. 30
So that's the new class and all getters and setters are not created so let's just discuss a little bit 31
about our ID field. 32
So the available time for ID field is long instead of. 33
And the reason for this is in the database we mean how millions of users. 34
So this malady that I play and may not be able to represent all these users there is a whole range of 35
and may not be large enough to represent all users. 36
So using a larger data type like long is definitely preferred now coming to user pipe freed. 37
It's basically a McAfee that is it identifies a user as either a regular user or some kind of a staff 38
member like editor or chief editor. 39
You may recall one of the effective doll items item 20 which said preferred class hierarchies but not 40
others. 41
So in this case we are violating that advice that is we are not maintaining separate classes for staff 42
members like editor and chief editor. 43
This also means that if we're looking at database tables we would have one table card user and that's 44
about it. 45
And it would have a column called user type although we are violating that advice from effective Java 46
. 47
It is fine in this case and there are a couple of reasons for this. 48
The main reason is we are treating this product as a web application. 49
And as mentioned earlier some of the implementation would be done differently from what was discussed 50
initially while introducing the concepts. 51
For example probably a probably new and rigid Proview type of methods will be part of some managers 52
as opposed to creating a class like editor and including these methods as part of them as we discussed 53
. 54
Well my learning inheritance Another reason is except for some additional privileges that staff members 55
have like approving a review or making a bookmark marking a bookmark as kid friendly. 56
They don't seem to have any additional unique features compared to a regular user that is there differ 57
only in user type value and all other fields are common to regular user and a staff member. 58
Next we will write bookmark classes and did it make sense to maintain separate classes for the different 59
bookmark types. 60
That is we would have a class hierarchy and not get back to us individual bookmark types like movie 61
and book have of that are unique to them. 62
In fact we used book market book and movie as an example to illustrate why we should use class hierarchies 63
are not classes. 64
While discussing that particular effect of Daleiden so it makes sense to have separate classes and even 65
indeed as we would have separate tables for movie book and bing. 66
OK. 67
So let's just go ahead and Corno it bookmarklet across us now. 68
OK so we are creating bookmark is now. 69
OK let's just create the bookmark class in the same package 70
not it's create three variables here 71
ID for you which is wrong as in the case of user class 72
. 73
So by do on the last one is profile you are in. 74
So once again let's create getters and setters select all 75
control shift have. 76
So that's the bookmark class. 77
So later we'll be making this an abstract class as we discussed in our lessons earlier. 78
That's because we want to introduce the kid friendly related methods and for that we need to make this 79
move more process abstract. 80
So we'll do that later. 81
Next let's add the movie class movie class. 82
We're extending the book Class this soon to me just say finish. 83
Now let's add this extends bookmark. 84
Save it now that's ired. 85
Some instance variables 86
say the first one is really easy either so. 87
And the more we the ear when the movies are released. 88
So it's it would be in type. 89
Next letter I cast so cast you how money to put our names. 90
So how does a string already 91
Next let's our directors. 92
So once again you mean how more than one director. 93
So let's go with string theory. 94
Next let's go to John Johnny. 95
You can Howard as a string. 96
Finally let's I'd reading. 97
Let's call it as I am rating just in gets If you don't know what I'm D-B is I'm D-B has website related 98
to movies and you can find ratings of movies over there. 99
So let's just have that reading as type as an honorable and once again or two generic gendered getters 100
and setters all. 101
So that's the movie and goodie. 102
Let's go had an our book and now 103
book also extends book mark. 104
You know that now let's ired publication either which can be and 105
I the publishers string 106
. 107
Now let's add authors since can have more than one author Bill Hobert does a string. 108
Next. 109
John Ray. 110
Now let's also have a rating for book. 111
Just like for a movie let's call it as Amazon rating so we will get the rating from Amazon. 112
Let's just assume that we have the rating from Amazon. 113
So once again it would be double counted as Amazon reading because there might be a separate wording 114
just within Trejos system also. 115
So in its name and let's keep it as clear as possible. 116
OK so that's a book. 117
Now let's create 118
a weblink 119
which also extends bookmark 120
and Webling to just how only two variables you Orlan host both of them strings 121
. 122
So that over blank glass now. 123
Good friendly status. 124
There's a fee for that. 125
And that way will later. 126
Finally let's create a user bookmark entity which would maintain the relationship between user and bookmark 127
. 128
That is if a user bookmarks a particular bookmark then that information is stored in this class. 129
So if we have a database then there will be a separate table made in just for this entity. 130
OK so there will be a table for user bookmark entity. 131
So let's just go ahead and create the user bookmark class 132
. 133
So it's just an independent class not extending any other class. 134
So it could have only two variables private user user. 135
And we also need a bookmark 136
is it after the user was the last one holes after bookmark 137
so that the user bookmark last. 138
I need food maintain the relationship between user and a bookmark. 139
So those are the entity classes that we have. 140
And next most likely we will implement the managed process