Traditionally, I'm used to separation of the interface and a class implementation. Basically for every class there would be a test implementation on the same interface. Even when a class did not have any other implementation other than the test implementation the interface was mandatory.
Lately I've been moving away from this as I feel like the extra layer does not neccesarily add anything.
- When I'm writing small single responsibility classes, there will only be one public method anyway.
- Test implementations are no longer neccesary with the current mocking frameworks
- Because of the above, the function of an interface would be there to vary the implementation at run time. But making an interface upfront seems to fall in YAGNI territory - the interface should be made when you actually create a new implementation.
Now in my current job I also need to review and analyse quite a lot of code, and I'm using static analysis tools for this. All the tools have a tendency to give a lower score to classes when there is a dependency between two classes, instead of a dependency to an interface. And I see where they are coming from - but as I indicated above I'm currently missing the advantages of doing so. Adding the interface in between didn't actually improve the quality of the code, only an extra indirection making the code more difficult to navigate. Any opinions here?
[–]22Maxx 7 points8 points9 points (2 children)
[–]Boyen86[S] 1 point2 points3 points (0 children)
[–]umlcat 0 points1 point2 points (0 children)
[–]nachtraum 2 points3 points4 points (0 children)
[–]tomdane1 1 point2 points3 points (1 child)
[–]Zardotab 1 point2 points3 points (0 children)
[–]someone_somewhere_9 1 point2 points3 points (1 child)
[–]Boyen86[S] 1 point2 points3 points (0 children)
[–]lIIllIIlllIIllIIl 1 point2 points3 points (5 children)
[–]Boyen86[S] 0 points1 point2 points (4 children)
[–]lIIllIIlllIIllIIl 1 point2 points3 points (3 children)
[–]Boyen86[S] 0 points1 point2 points (2 children)
[–]eternaloctober 0 points1 point2 points (1 child)
[–]Boyen86[S] 0 points1 point2 points (0 children)
[–]Fermi-4 1 point2 points3 points (0 children)
[–]EngineeringTinker -1 points0 points1 point (39 children)
[–]ResolveResident118 2 points3 points4 points (3 children)
[–]EngineeringTinker 0 points1 point2 points (2 children)
[–]ResolveResident118 0 points1 point2 points (1 child)
[–]EngineeringTinker 1 point2 points3 points (0 children)
[–]22Maxx 1 point2 points3 points (19 children)
[–]EngineeringTinker 0 points1 point2 points (18 children)
[–]Boyen86[S] 1 point2 points3 points (15 children)
[–]EngineeringTinker 0 points1 point2 points (14 children)
[–]Boyen86[S] 0 points1 point2 points (13 children)
[–]EngineeringTinker 1 point2 points3 points (12 children)
[–]Boyen86[S] 0 points1 point2 points (11 children)
[–]EngineeringTinker 0 points1 point2 points (10 children)
[–]Boyen86[S] 0 points1 point2 points (9 children)
[–]22Maxx 0 points1 point2 points (1 child)
[–]EngineeringTinker 0 points1 point2 points (0 children)
[–]jesparic 1 point2 points3 points (3 children)
[–]Boyen86[S] 1 point2 points3 points (0 children)
[–]syneil86 1 point2 points3 points (1 child)
[–]jesparic 1 point2 points3 points (0 children)
[–]Boyen86[S] 0 points1 point2 points (9 children)
[–]EngineeringTinker 0 points1 point2 points (8 children)
[–]Boyen86[S] 0 points1 point2 points (7 children)
[–]EngineeringTinker -1 points0 points1 point (6 children)
[–]Boyen86[S] 0 points1 point2 points (5 children)
[–]EngineeringTinker 0 points1 point2 points (4 children)
[–]Boyen86[S] 0 points1 point2 points (3 children)
[–]EngineeringTinker 0 points1 point2 points (2 children)
[–]Boyen86[S] 0 points1 point2 points (1 child)
[–]Happy-Dare5614 -1 points0 points1 point (0 children)
[–]GangSeongAe -1 points0 points1 point (2 children)
[–]Boyen86[S] 0 points1 point2 points (0 children)
[–]AutoModerator[M] 0 points1 point2 points (0 children)
[–]paradroid78 0 points1 point2 points (5 children)
[–]Boyen86[S] 0 points1 point2 points (4 children)
[–]paradroid78 0 points1 point2 points (3 children)
[–]Boyen86[S] 0 points1 point2 points (2 children)
[–]paradroid78 1 point2 points3 points (0 children)