• Post Reply Bookmark Topic Watch Topic
  • New Topic

how coupling is implemented in java programming wise?  RSS feed

 
anish jain
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to implement coupling in java? please provide some code snippets highlighting this
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "coupling"?
 
anish jain
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
coupling is the degree to which an object depends on other object
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What would "implementing coupling" mean?
 
Campbell Ritchie
Marshal
Posts: 56562
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Surely you want to avoid coupling?

Find a book like "Code Complete" by Steve McConnell, which (I think) has sections about coupling and coherence in.
 
Siddhesh Deodhar
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
coupling is the degree to which an object depends on other object


True, you can find many articles on google on the topic. According to good OO practices coupling should be less. According to coupling, each class should show its functionality to outside world through an interface.Other classes should see this interface and should understand what that class does. e.g.

interface DogInterface
{
walk();
run();
bark();
}

class Dog implements DogInterface
{
//...implementations
}

This is not possible to do always.. but if its done , its good.

 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Surely it's a homework assignment, no? If so, then the FAQ's might be worthwhile reading.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Siddhesh Deodhar wrote:According to coupling, each class should show its functionality to outside world through an interface.

It goes beyond that, though.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may find this article on "Dependency Injection." of interest.

Bill
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!