Does ‘Encapsulation’ help develop multiple modules parallely?

After going through SO questions, I learnt that, Encapsulation is about protecting invariants and hiding implementation details.

From class room java training, I learnt that, Encapsulation has following advantages,

Why encapsulation is your friend?

[1] The implementation is independent of the functionality. A programmer
who has the documentation of the interface can implement a new version
of the module or ADT independently. A new, better implementation can
replace an old one.

[2] Encapsulation prevents Doug from writing applications that corrupt a
module’s internal data. In real-world programming, encapsulation
reduces debugging time. A lot.

[3] ADTs can guarantee that their invariants are preserved.

[4] Teamwork. Once you’ve rigorously defined interfaces between modules,
each programmer can independently implement a module without having
access to the other modules. A large, complex programming project can
be broken up into dozens of pieces.

[5] Documentation and maintainability. By defining an unambiguous
interface, you make it easier for other programmers to fix bugs that
arise years after you’ve left the company. Many bugs are a result of
unforeseen interactions between modules. If there’s a clear
specification of each interface and each module’s behavior, bugs are
easier to trace.

[6] When your Project doesn’t work, it will be easier to figure out which
teammate to blame.

My observation says, Point 2 is in alignment with the definition of Encapsulation. I completely agree with Point 3 but has nothing to do with Encapsulation.

Question 1:

When point 1(above) says, documentation of the interface, What is interface here? Can you give an example from jdk?

Question 2:

I am completely clueless about Point 4, How Encapsulation help programmer to independently implement module without having access to other modules? Is it through Java interface? If yes, How this parallel implementation of modules has anything to do with Encapsulation?


Source: oop

Leave a Reply