Joke Collection Website - Public benefit messages - The meaning and function of encapsulation, and what does the factory method mean?

The meaning and function of encapsulation, and what does the factory method mean?

I didn't see any official information in this piece, just summed it up myself. Java is an object-oriented development language. The first advantage of this language is that it standardizes the team development method. The second advantage is that if you have seen C language development (process-oriented), you will find how readable the object-oriented language is.

An encapsulated class or interface. The team leader role in the team defines fixed methods and variables. After providing, team members inherit or implement. Avoid methods with the same name to realize different functions. Usually, it is suitable for implementing tool classes or the following requirements. For example, a linked database must use the getLink method. In this way, the getLink method uses an encapsulated or interface. You can prevent others from developing their own scripts to link databases or using other names to link databases.

2. Privatization variables. Since it is a team development, there will definitely be some commonly used variables, and team members may not modify them at will. After the privatization of variables, team members are not allowed to functionally modify private variables of encapsulated classes.

In a word, personal understanding, encapsulation and privacy improve the readability and standardization of the interface, which are all functions that bring convenience to team development.