2

When developing with Symfony2 PHP framework I often see reccomendations to decouple code but most of the time that is accompanied by a 'if you want to release as a third party bundle'.

Which begs the questions, if my software is proprietary should I even bother to decouple it for e.g., using interfaces and models (abstract classes) for defining domain objects. You can use an ORM and create entities which extend from models and if you want to change to an ODM you can create a Document which extends from the model. This is just an example, there are more like having a UserManager which implements a UserManagerInterface (why need this in proprietary software which is never gonna be released to the public).

Decoupling to me looks more like a way to satisfy all needs when releasing your code as open source, which can adapt to most needs.

  • possible duplicate of [Rule of thumb for cost vs. savings for code re-use](http://programmers.stackexchange.com/questions/127118/rule-of-thumb-for-cost-vs-savings-for-code-re-use) – gnat Jul 01 '15 at 13:05

1 Answers1

6

You couldn't be more wrong.

Decoupling is not for the benefit of third-party integrators who might want to take one of your components and rig it together with someone else's other component. The entire idea of reusable software objects that might be sold separately has been a gigantic disappointment, because it's simply too difficult to define clearly and umabiguously want precisely it is that a component is supposed to do.

The benefit is rather that modularized software with isolated parts is far easier to think about and work with, even when all the parts were written by yourself. This is an effect that only becomes perceptible when you program "in the large", beyond the threshold where you can actually hold all details in your head simultaneously. For that reason, there is never a shortage of beginners who think that as geniuses, they don't need structure, modules or visibility restrictions; this is part of the reason why there are so many large projects with an atrociously bad architecture.

In short, decoupling is a good idea because it helps you understand your own creation better. You should only disregard it if you really are a genius (and have no collaborators).

Kilian Foth
  • 107,706
  • 45
  • 295
  • 310
  • I already decouple my code but I've always wondered if this is even helping. Maybe you need to decouple but to a certain degree. –  Jul 01 '15 at 12:40
  • I don't know, there are companies that make a living selling components (eg UI grid controls) and there are many who provide components for free (eg OSS libs like openssl, tinyxml, ffmpeg, log4net, to name a tiny number). You are right that many commercial developers making general software have failed at producing isolated components... but this is because they suck (oh ok, ... are too inexperienced or have no time or inclination to define the interface boundaries properly) – gbjbaanb Jul 01 '15 at 12:52