Questions tagged [coupling]

197 questions
7
votes
6 answers

Detecting dependencies between namespaces in .NET

Are there any utilities that can examine a set of managed assemblies and tell you whether any of the types in one namespace depend on any in another? For example, say I have a MyApp.BusinessRules namespace and don't want it to access directly…
Mark Heath
  • 48,273
  • 29
  • 137
  • 194
7
votes
3 answers

Reducing coupling simple example needed for beginner

Just out of college and am coming across some code where I need to reduce coupling. But I don’t understand fully all the concepts and would like a simple example to help me. To get you started I have a person class with a single field, name. I have…
Francis Rodgers
  • 4,565
  • 8
  • 46
  • 65
6
votes
6 answers

How to refactor tightly coupled classes?

I'm trying to refactor a big tightly coupled application and trying to make it more maintainable and flexible. I've got many unit tests, so I'm hoping to refactor step by step. Which Design & Refactoring Patterns should I consider implementing /…
dr. evil
  • 26,944
  • 33
  • 131
  • 201
6
votes
1 answer

Best option for managing module classes

My game base consists of a series of modules, organized as classes, that are created, updated and interact when needed. A few examples could be: CWindowManager, CGraphicsManager, CPhysicsManager, and so on. I'm ashamed to have to say that I…
TDS
  • 61
  • 1
6
votes
2 answers

How to reduce coupling when one class calls only one method on another class that has many methods?

I have a class (let's call it MyService) that accepts two dependencies in it's constructor. The first one is not all that relevant to the question. The second one is PaymentDetails. PaymentDetails lives for longer than the MyService, which is…
WW.
  • 23,793
  • 13
  • 94
  • 121
6
votes
2 answers

Java 1.4: Cast primitive type to Object (Coupling vs Performance?)

This is actually related to a question I asked earlier, but I was left hanging on this detail. I'm restricted to Java 1.4 and I want to cast an int type to Object. Do I really need to use an Integer class object or there's a way to cast it directly…
makoshichi
  • 2,310
  • 6
  • 25
  • 52
6
votes
4 answers

Is Polymorphism worth an increase in coupling?

I'm writing a simplistic game to learn get some more C++ experience, and I have an idea where I feel polymorphism almost works, but doesn't. In this game, the Party moves fairly linearly through a Map, but can occasionally encounter a Fork in the…
MighMoS
  • 1,228
  • 8
  • 18
6
votes
7 answers

When classes want to couple

I am having an issue with 2 classes that were once nicely separated, but now they want to couple. Without getting too much into the specifics of the problem, here it is: I used to have a class Triangle that contained 3 space-position vertices. class…
bobobobo
  • 64,917
  • 62
  • 258
  • 363
6
votes
2 answers

How would you improve this simple class to be more loosely coupled?

As you can see below, in the constructor I'm instantiating a validation object so I can validate a user's email in a set method. Is this architecture best practice or flawed? Can I avoid making my User class directly dependent on my Validation…
Cory House
  • 14,235
  • 13
  • 70
  • 87
6
votes
6 answers

Don't low coupling and high cohesion depend on each other?

I am supposed to write two versions of the same code. One with low coupling and high cohesion and another still with low coupling but this time with low cohesion. I don't really understand what the difference is? How can I have low coupling and low…
qwerty qwerty
  • 147
  • 1
  • 6
5
votes
3 answers

Which design supports low coupling?

Which Design supports overall low coupling? and why?
user478636
  • 3,304
  • 15
  • 49
  • 76
5
votes
3 answers

Law of Demeter and return values

According to the Law of Demeter, can you call methods on returned objects? E.g. get('http://www.google.com'); return $response->getBody(); // violation? …
Sjoerd
  • 74,049
  • 16
  • 131
  • 175
5
votes
1 answer

When is tight coupling essential or a good thing?

From all my readings and research on OO design/patterns/principles I've found that the general consensus is that loose coupling (and high cohesion) is the almost always the better design. I completely agree speaking from my past software project…
Nah
  • 331
  • 2
  • 9
5
votes
4 answers

Loose coupling vs Encapsulation. Best approach for a balanced design

According to the next examples: class InvoiceGenerator { function create(Invoice $invoice) { $invoice->create(); } } class InvoiceGenerator { function create($invoiceData) { $invoice = new Invoice(); …
Luis Martin
  • 910
  • 3
  • 14
  • 31
5
votes
5 answers

Alternatives to the "using" directive keyword in C#?

I just finished watching an episode of Bob Martin at NDC where he said "using" directives in C# at the top of a page are bad because of the tight coupling they create/imply between components. What way are there to use external .dlls without adding…
MatthewMartin
  • 32,326
  • 33
  • 105
  • 164
1
2
3
13 14