Questions tagged [loose-coupling]

207 questions
6
votes
4 answers

I know how to use dependency injection but I recognize no practical advantage for it

It is about this (Inject the dependency) private readonly ICustomerService _customerService; public Billing(ICustomerService customerService) { _customerService = customerService; } versus this (Create the dependency) private readonly…
msfanboy
  • 5,273
  • 13
  • 69
  • 120
6
votes
2 answers

What is the recommended way for a model to communicate with a view controller?

For instance, I have a model class which handles receiving bluetooth messages from other iPhones. When I receive one of these messages, I need to update a view. I believe the standard way of doing this is through the view controller. The view…
Tom H
  • 1,316
  • 14
  • 26
6
votes
1 answer

Micro-services architecture loose coupling complications

I'm fairly new to the whole micro-services bandwagon. I have been doing some research into the architecture and principles behind a good micro-services environment. One of the main things that defines a micro-service is supposed to be the loosely…
Gers
  • 338
  • 3
  • 9
6
votes
3 answers

optimization of high cohesion and loose coupling

I was questioned in a technical interview about cohesion and coupling of a project. I extensively explained their definitions, although I did not answer the second part of the question properly, as he said. "How could we achieve a highly cohesive…
Ali K. Nouri
  • 495
  • 5
  • 18
6
votes
2 answers

Laravel4 The benefit of IOC container

I have trouble understanding the benefit of the IOC container in the scope of dependency injection. Considering this basic example: App::bind('Car', function() { return new Car; }); Route::get('/', function() { dd(App::make('Car')); // …
html_programmer
  • 18,126
  • 18
  • 85
  • 158
5
votes
3 answers

MVC 3 passing entity as an Interface

I'm currently working on an MVC 3 project using Ninject as my DI, the business objects are stored in a separate assembly. I'm running into an issue with the controller parameters, when posting back for CRUD operations I'm getting the error "Cannot…
5
votes
2 answers

How do you decouple Web Components?

I'm trying to work frameworkless, with pure javascript Web Components. I want my Web Components to be able to work stand-alone and be used on different sites, and yet I also want two components to be able to communicate. So they should be able to…
mcv
  • 4,217
  • 6
  • 34
  • 40
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
4 answers

Do events really make code decoupled?

So I am trying to use events to decouple code that I have and here is my problem: class WorldHandler { public void Notify(object sender, EventArgs e) { if (e is CameraMovedEventArgs) { // handle event } …
martynaspikunas
  • 485
  • 5
  • 15
5
votes
2 answers

Loosely coupled observer pattern

I realise this subject has been covered to death but I am still struggling and could do with some specific help. My aim is to implement a simple Observer pattern between some kind of observable (lets say a Dog) and some kind of listener (lets say…
5
votes
2 answers

Loose coupling with Class.forName()

interface Bank { void connect(); } class SBI implements Bank { static{ System.out.println("Hello from SBI static"); } public void connect() { System.out.println("Connected to SBI"); } } class…
Testaccount
  • 2,755
  • 3
  • 22
  • 27
5
votes
1 answer

Unit converting design pattern in C#

I need to make conversions between units, each unit has 2 parts, its name and an integer, the integer part can be either positive or negative. I need my Unit class to have dependency injection and be loosely coupled. For example if I need to add…
4
votes
6 answers

Are there other benefits to loosely coupled code besides TDD?

When I'm doing TDD, it forces me to employ Dependency Injection principle and I end up with loosely coupled code. I was told that it's harder to understand application that has loosely coupled code. Can you tell me what pros and cons of loosely…
Vadim
  • 21,044
  • 18
  • 65
  • 101
4
votes
2 answers

How do I have an object subscribe to another's event while keeping the two loosely coupled?

I have the following bits of code which, in my mind, seem like the bare basics necessary to implement the Observer pattern. Is this standard, or am I doing something wrong? public class LayoutManager { public CormantTimer Timer { get; set;…
Sean Anderson
  • 27,963
  • 30
  • 126
  • 237
1
2
3
13 14