1

00:00:01,130  -->  00:00:04,980
End this demo let's unhandsome a student example.

2

00:00:04,980  -->  00:00:06,960
And here is the Student class.

3

00:00:06,960  -->  00:00:09,570
It is the same class we wrote earlier.

4

00:00:09,690  -->  00:00:18,390
Only change I made as to public modify our new class declaration reliables constructor and update profile

5

00:00:18,390  -->  00:00:26,290
method and that's for the sake of this demo site no expose's instance fields with public modifier veen

6

00:00:26,320  -->  00:00:32,940
are that it is a bad design which leads to tight coupling so let's incorporate the sedation for effective

7

00:00:33,220  -->  00:00:33,460
.

8

00:00:33,510  -->  00:00:41,140
Item 14 it does make instances by weight and access them using getters and setters.

9

00:00:41,190  -->  00:00:43,370
So let's go ahead and make this change.

10

00:00:43,740  -->  00:00:46,590
So let's make all instance variables private

11

00:00:53,310  -->  00:00:56,170
just copy this.

12

00:00:57,870  -->  00:01:01,190
OK so now all the instance fields are by weight.

13

00:01:01,620  -->  00:01:06,400
Let's also add again an answer for just the name field.

14

00:01:07,740  -->  00:01:10,330
And it needs to be public.

15

00:01:11,720  -->  00:01:12,180
That's.

16

00:01:12,270  -->  00:01:15,390
I'd get her name

17

00:01:16,850  -->  00:01:24,470
.

18

00:01:26,190  -->  00:01:28,040
It's out of Sekar

19

00:01:40,360  -->  00:01:43,580
it's initialized instance really.

20

00:01:43,650  -->  00:01:47,150
So does not mean equals name.

21

00:01:47,220  -->  00:01:51,370
So that's the setter on the getter and the instance variables are private.

22

00:01:51,720  -->  00:01:53,390
Let's also change the constructor.

23

00:01:53,400  -->  00:02:00,450
So here we have constrictors and the name is getting initialized in this overloaded constructor which

24

00:02:00,450  -->  00:02:03,330
is it which is being invoked from here.

25

00:02:04,110  -->  00:02:05,550
So let's just change this.

26

00:02:05,670  -->  00:02:12,630
So let's just how only one single construct or sort let's make a gender here and let's just remove this

27

00:02:12,780  -->  00:02:14,880
entire constructor and let's keep it simple

28

00:02:23,290  -->  00:02:30,000
ones name.

29

00:02:32,760  -->  00:02:38,750
So we now have a single constructor and we have the update profile Materne here.

30

00:02:39,090  -->  00:02:43,150
And here is the student class from here.

31

00:02:43,320  -->  00:02:47,130
If you recall we are actually creating the student objects from here.

32

00:02:47,220  -->  00:02:53,740
We are creating three student objects initializing their state and printing their names.

33

00:02:54,060  -->  00:02:59,940
And one of the names has been misspelled as Joanne serviette invoking the dead profiled method here

34

00:03:00,030  -->  00:03:01,960
and passing the right name.

35

00:03:02,130  -->  00:03:06,710
And then we are printing the right name after updating the profile.

36

00:03:07,290  -->  00:03:11,490
And over here we are in the gender field.

37

00:03:11,760  -->  00:03:14,690
And right now gender field is by red.

38

00:03:14,700  -->  00:03:15,680
That's what we did.

39

00:03:15,900  -->  00:03:17,500
So this should not compile.

40

00:03:17,760  -->  00:03:18,420
Right.

41

00:03:18,420  -->  00:03:22,850
And even here this constructor we have changed the constructor.

42

00:03:22,860  -->  00:03:27,920
So we have to pass the right gender.

43

00:03:28,290  -->  00:03:30,830
So let's let's just do that.

44

00:03:32,160  -->  00:03:33,810
You just pass me here

45

00:03:36,220  -->  00:03:42,050
or IGE is male and then what.

46

00:03:42,060  -->  00:03:48,590
Anita it's female but gender is still a primate and we cannot access it.

47

00:03:48,630  -->  00:03:55,480
So let's just compile and see.

48

00:03:55,650  -->  00:03:58,140
So here it says gender has private access.

49

00:03:58,170  -->  00:04:04,930
And student so we cannot access it directly so we can just remove this.

50

00:04:04,950  -->  00:04:11,970
In fact we don't have to get a it not how to get her back and we don't need a sitter because we are

51

00:04:11,970  -->  00:04:20,150
sitting here from the concert or Pettit's And so let's just go ahead and delete these three statements

52

00:04:22,780  -->  00:04:30,090
and also instead of a big profile Let's actually said that mean said the correct name because we added

53

00:04:30,090  -->  00:04:33,080
a setter and it's just said the correct name.

54

00:04:33,080  -->  00:04:41,200
So let's just change this to set me.

55

00:04:42,030  -->  00:04:48,530
And also here we cannot access it so it needs to be get mean.

56

00:04:48,840  -->  00:04:51,480
So we are calling to get mean.

57

00:04:51,660  -->  00:04:59,590
So we use only setters and getters no more direct access.

58

00:04:59,930  -->  00:05:04,870
And hopefully this should compile fine.

59

00:05:06,440  -->  00:05:07,500
Excellent.

60

00:05:07,920  -->  00:05:10,140
And it's good on this.

61

00:05:10,140  -->  00:05:10,610
That's it.

62

00:05:10,650  -->  00:05:17,090
So we are printing the three students names and then we have the correct name because this was misspelled

63

00:05:17,280  -->  00:05:20,620
and we are printing the right name here.

64

00:05:21,040  -->  00:05:22,580
And that's about it.

65

00:05:22,710  -->  00:05:26,500
So that's information hiding rule.

66

00:05:26,760  -->  00:05:33,780
And it's also an off Joshua blocks favorite information hiding rule.

67

00:05:34,680  -->  00:05:35,580
And that's at
