About Question enthuware.ocajp.i.v7.2.1213 :
Moderator: admin
About Question enthuware.ocajp.i.v7.2.1213 :
Hi
What is the exact difference between coupling and encapsulation?
Thanks a lot in advance.
The_Nick
What is the exact difference between coupling and encapsulation?
Thanks a lot in advance.
The_Nick
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1213 :
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.
Encapsulation basically hides the instance variables by making them private. This reduces coupling because other classes cannot directly access those fields.
If you like our products and services, please help us by posting your review here.
-
- Posts: 15
- Joined: Fri Jul 12, 2013 12:34 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1213 :
Found another nice explanation:
http://www.coderanch.com/t/411693/java/ ... esion-java
http://www.coderanch.com/t/411693/java/ ... esion-java
-
- Posts: 18
- Joined: Thu May 23, 2019 11:58 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1213 :
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?
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?
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1213 :
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
If you like our products and services, please help us by posting your review here.
-
- Posts: 60
- Joined: Thu Apr 15, 2021 12:21 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1213 :
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.
"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.
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1213 :
Fixed.
thank you for your feedback!
thank you for your feedback!
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: Bing [Bot] and 105 guests