Page 1 of 1

About Question enthuware.ocajp.i.v7.2.1213 :

Posted: Wed Mar 06, 2013 2:02 pm
by The_Nick
Hi
What is the exact difference between coupling and encapsulation?
Thanks a lot in advance.

The_Nick

Re: About Question enthuware.ocajp.i.v7.2.1213 :

Posted: Wed Mar 06, 2013 3:29 pm
by admin
Coupling means how interconnected classes are. Tight coupling means that the classes know a lot of internal details such as instance fields and methods (which are not exposed by an interface) of each other.

Encapsulation basically hides the instance variables by making them private. This reduces coupling because other classes cannot directly access those fields.

Re: About Question enthuware.ocajp.i.v7.2.1213 :

Posted: Thu Sep 19, 2013 3:54 am
by TheSarjo

Re: About Question enthuware.ocajp.i.v7.2.1213 :

Posted: Tue Aug 27, 2019 5:38 am
by hamzaBlm
I understand than Encapsulation does its job to reduce coupling between classes by hiding internal details.

My question is:
Can we reduce coupling by following the principle of "program to interfaces not to implementations"?

I think by following the principle we can have low coupling because now the classes depend on the interface, not the implementation. am I correct?

Re: About Question enthuware.ocajp.i.v7.2.1213 :

Posted: Tue Aug 27, 2019 7:39 am
by admin
The measure of these parameters is quite subjective. So, yes, one could argue that. But it would not be too beneficial to discuss this here as we are focused more on the certification. You will get better answer for it on sites such as coderanch.com

Re: About Question enthuware.ocajp.i.v7.2.1213 :

Posted: Sat Jul 24, 2021 6:28 am
by enthunoob
May I suggest a bit of interpunction just to improve the absolute dive readability of this sentence:

"When a class, whose members should be accessible only to members of that class, is coded such a way that its members are accessible to other classes as well, this is called ..."


Instead of

"When a class whose members should be accessible only to members of that class is coded such a way that its members are accessible to other classes as well, this is called ..."

Assuming 'decrypting' of code is part of the exam, but not decrypting of bad spelling.

Re: About Question enthuware.ocajp.i.v7.2.1213 :

Posted: Wed Jul 28, 2021 7:17 am
by admin
Fixed.
thank you for your feedback!