Showing posts with label Patterns. Show all posts
Showing posts with label Patterns. Show all posts

Monday, 21 September 2015

The Dependency Inversion Principle And The Dependency Injection Pattern

Following on from a previous blog about Inversion of Control, I intend to continue by discussing the patterns identified in that article as being IoC patterns, or rather implementation patterns which enable the application of the IoC concept. Specifically in this post we will be looking at the Dependency Injection pattern, which will be followed up by a post on the Service Locator anti-pattern.

What is the Dependency Inversion Principle?

The dependency inversion principle refers to a specific form of decoupling software modules. When following this principle, the conventional dependency relationships established from high-level, policy-setting modules to low-level, dependency modules are inverted (i.e. reversed), thus rendering high-level modules independent of the low-level module implementation details.

Monday, 14 September 2015

Did Uncle Bob get it wrong? ... a question not posed lightly

I don't mind admitting that I am a huge fan of Robert (Uncle Bob) C. Martin. I've read so much of his published material and I think he has a great deal of important stuff to say. His videos are fantastic too, you must have seen them? Well if not then I strongly suggest you search for him on youtube; there's oodles of great stuff on there all ready for your viewing pleasure.

I have always taken everything I've read or heard from Uncle Bob very seriously. I've been reading a lot of stuff on his blog (I hope he doesn't mind the link, but I'm sure it will be fine)

Anyway it is with great reluctance that I posit the notion with this question ...

Did Uncle Bob get it wrong?

One blog in particular from Uncle Bob caught my eye recently, it is entitled 'Interface' Considered Harmful and can be found here

I lapped it up, every word that had been carefully selected so as not to leave room for ambiguity. I thought it was a great post and that it helped me to realize just what it was that was bugging me about .Net. There was this little itch when I consider C#. Don't misunderstand me at all, C# is my language of choice these days, but there was something niggling away at the back of my mind and reading that blog entry brought it right to the fore.

Friday, 13 April 2012

Runtime Exceptions: what is the true cost of reliance upon them?

Abstract

It is a common belief that the .Net framework provided System.Exception and its derived classes should be avoided when they are not absolutely essential, and that instead; meaningful, alternate, less expensive solutions should be sought out and applied. Expense in this instance refers to both the physical cost of resources (RAM, processing cycles, etc.) and the fiscal cost of maintaining and developing against code which utilises Exceptions.

Although there exist articles and publications which appear to recommend the use of Exceptions, this interpretation is misguided. Exceptions do have a run time cost, and they do have a development cost, this essay finds that avoidance of Exceptions is the preferred development technique, and that there are various industry standard Patterns for achieving this end.