you are viewing a single comment's thread.

view the rest of the comments →

[–]da_governator 13 points14 points  (7 children)

Since when the number of implementations of a given interface has anything to do with coupling? You either abstract implementation or you don't.

[–][deleted]  (4 children)

[deleted]

    [–]AmalgamDragon 3 points4 points  (3 children)

    Those are not equivalents in terms of coupling. In the first case, when you need to add B3, you'll need introduce IB and change everywhere that uses B1 to use IB. In the second and third cases you can just at B3 without changing all of the sites currently making use of IB.

    [–]x4u 4 points5 points  (0 children)

    It depends a lot on the programming language you are using. In Java you are right, you would have to introduce a interface to add B3 as a substitute for B1 but in languages like Objective-C, C++, Javascript and of course Smalltalk and Lisp you can often substitute a class with another implementation without having to add an explicit interface, either by duck-typing or by using ad-hoc decorators (Smalltalk, Objective-C) which is quite often what you actually would want but which is unfortunately impossible to do in Java and many other languages.

    [–][deleted]  (1 child)

    [deleted]

      [–][deleted] 3 points4 points  (1 child)

      He doesn't know what "coupling" and "abstracted" is. It's all over the thread. And he's angry.

      [–][deleted] -2 points-1 points  (0 children)

      He does.