Materials used </ b> ・ A refreshing introduction to Java ・ Java SE 7/8 Bronze Questions (Kuromoto)
It's confusing while learning Java Bronze! I will summarize the concepts "encapsulation", "data hiding", and "information hiding" that I thought. The difference between encapsulation, information hiding, and data hiding is not clarified in "Introduction to Java that can be clearly understood" (the terms "data hiding" and "information hiding" do not appear in the first place), so please refer to the contents of the Java black book. I will.
"1. Collect related data" "2. Collecting processes that require collected data"
"Do not allow direct manipulation of fields from the outside"
Purpose: Maintaining encapsulation </ b>
Prevents the data aggregated by encapsulation from being used by modules other than the aggregated ones to complicate the relationship.
Implementation method </ b> -Prohibit field operations from the outside by making the access modifier private -If you want to access the field, use methods (accessor methods) called getter and setter (not required).
"Distinguish between what should be made public and what should be kept private"
Purpose: Maintaining the effect of abstraction </ b>
The abstraction simplifies the relationships between the modules. If the "user" uses a module on the "user" that should have been ignored by the abstraction, the relationship becomes complicated. Information is shielded to avoid this
Implementation method </ b> ・ Public part → Publish as an interface · Private part → Control improper access using package access modifiers
・ Relationship with polymorphism
Recommended Posts