Wednesday, July 18, 2018

I've seen some tweets this morning about the bridge pattern so I guess that merits a blog posting.

It's an old Gang of Four thought put to paper in published book form. It has to do with attempts to untie external dependencies from interfaces in the whole Inversion of Control subset of maintainability in the bigger picture. We all have gotten pretty good at IoC, eh? We don't really need to geek out on this now. You no longer need StructureMap in .NET Core and if you are using the .NET Framework, well, you can probably just use StructureMap. I have blog postings on using StructureMap with web forms while not using the old ObjectFactory approach which has been disallowed in modern StructureMap. The hacks there may be overkill however. Guys, if you do IoC without .NET Core and without a tool like StructureMap to help you, you are basically just upcasting external dependencies to interfaces that are implemented by them and then passing the interfaces in to method signatures where they will get used instead of the external dependencies themselves. It's really all that simple. It can be more complicated to be more elegant, but when you take away all of the whistles and bells we are talking about using interfaces for the one use case wherein interfaces are most important and cannot be skipped.

No comments:

Post a Comment