1

00:00:01,060  -->  00:00:07,320
In the last lesson VSA how setters and getters can be used to prevent direct access of of us.

2

00:00:07,870  -->  00:00:09,560
But it's not just variables.

3

00:00:09,580  -->  00:00:15,970
We also want to be careful about what methods and classes we are exposed to external code that is there

4

00:00:15,970  -->  00:00:19,660
can be tight coupling to even methods and classes.

5

00:00:19,840  -->  00:00:25,540
So we will not look at another effective July time that gives some more advice on how we can go about

6

00:00:25,540  -->  00:00:27,580
hiding information.

7

00:00:27,580  -->  00:00:33,960
The item is item 13 and it says minimize the accessibility of classes and members.

8

00:00:34,420  -->  00:00:41,290
Let's review what it has to say and it's going to be a sharp lesson when it comes to designing class

9

00:00:41,300  -->  00:00:48,620
members here is a general solution from the item just carefully design a minimal public API of your

10

00:00:48,620  -->  00:00:55,810
class so once you have an idea of the variables on matters that go into your class just carefully look

11

00:00:55,810  -->  00:01:02,440
at all the class members and see which of them will really be needed by the clangor and just make them

12

00:01:02,440  -->  00:01:06,790
public all that how many members should be made private.

13

00:01:08,650  -->  00:01:15,190
Only if an class in the same package really needs access to a private member then you would convert

14

00:01:15,190  -->  00:01:22,480
it to the default access and same holds for converting something into public member.

15

00:01:22,480  -->  00:01:28,870
Now if you find yourself doing such conversions often then you may want to re-examine your design probably

16

00:01:28,870  -->  00:01:30,820
structuring your classes in a different way.

17

00:01:30,840  -->  00:01:32,300
Could be a better solution.

18

00:01:33,980  -->  00:01:41,630
Come into classes or interfaces vino that they can hire only public publico default access lever's surfer

19

00:01:41,640  -->  00:01:47,910
class or interface can have default as accessible then liquored have default access level because once

20

00:01:47,910  -->  00:01:51,580
it is public you would be obligated to support it for whatever.

21

00:01:51,990  -->  00:01:55,760
So basically give the client code access to only what they need.

22

00:01:57,660  -->  00:02:04,020
Match within your package if a class is used by only one other class then consider making that class

23

00:02:04,140  -->  00:02:07,870
a private master class within the class that uses it.

24

00:02:08,320  -->  00:02:14,150
Mr. Crossus will be introduced much later but it is simply a class that an underclass like in the strict

25

00:02:14,210  -->  00:02:21,690
follow up it simply exists to serve its enclosing class so that's about information hiding.

26

00:02:21,740  -->  00:02:28,340
So we software design principles that use access modifiers to achieve information hiding information

27

00:02:28,340  -->  00:02:34,980
hearting helps in building well-designed design software which then loosely coupled components as you

28

00:02:34,980  -->  00:02:37,930
can see the principles are pretty straightforward.

29

00:02:37,980  -->  00:02:42,310
Generally I think double uppers do use accessor methods for class members.

30

00:02:43,230  -->  00:02:47,860
However when it comes to classes they don't follow the advice that we see here.

31

00:02:47,880  -->  00:02:51,140
They usually make the classes public all the time.

32

00:02:51,180  -->  00:02:56,640
It may not be an issue at all if your code is never used outside your company but if you're writing

33

00:02:56,640  -->  00:03:03,150
code that will be used by public or your partners then you must follow the advice given in this lesson

34

00:03:04,470  -->  00:03:11,050
just know that this advice comes from Joshua ablock who has written tons of July API called on so it

35

00:03:11,050  -->  00:03:18,150
would serve us well if you take his advice seriously Also one last comment I would like to make is sometimes

36

00:03:18,150  -->  00:03:25,190
people refer to encapsulation as information hiding in our case they're introduced us separate concepts

37

00:03:25,450  -->  00:03:32,440
and that is very widely acceptable as we look at them so just want to highlight that sometimes you may

38

00:03:32,470  -->  00:03:37,090
come across people using the term encapsulation for information hiding.

39

00:03:37,270  -->  00:03:43,050
But you know what that mean in fact the supplementary notes includes a link to a great article on this

40

00:03:43,050  -->  00:03:46,270
topic and you can check it out in your free time.

41

00:03:46,530  -->  00:03:47,560
And that's about it.

42

00:03:47,670  -->  00:03:48,100
Thank you
