• Post Reply Bookmark Topic Watch Topic
  • New Topic

coupling in java  RSS feed

 
Somu Sundaram
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am not able to comprehend the concept of coupling with respect to interface vs concrete class and abstract class vs concrete class.

there is a loose coupling between an interface and the class that implement it. but changes made to the interface(such as variable name or method name change) affects the class that implement it. the reverse is not true here.
i find things similar in the case of abstract class vs concrete class. but here it is called tight coupling.

can somebody explain what actually happens here.


Thanks and Regards,
S Somu
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Extending a base class or implementing an interface is pretty darned strong coupling. If the abstraction (base class or interface) is stable - doesn't change very often relative to the implementations - it's acceptable because it allows some other good things to happen. "Stable abstractions" is a design goal, and it's interesting to measure over time whether you picked the right abstractions.

Among the good things that happen ... Other classes can depend on the abstraction and not on the concrete class, so they are loosely coupled or maybe even not coupled to the implementation. The down side of coupling is the more object A knows about object B the more likely a change to B will break A. If the only thing A knows about B is that it implements some interface, we're in a pretty good place.

Does that make sense? Raise more questions?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!