There are certain constructs in programming languages that demonstrably lead to bad code in the vast majority of use-cases. There is a term for these constructs: anti patterns. An anti-pattern is a way of solving a problem that often appears quick and simple, but that leads to more work and more problems in the long run. Think of nailing two pieces of wood together, rather than drilling a guide hole and using a screw. The former is quicker, but the repair when the wood splits can be both costly and time consuming. Programming languages can enable, and sometimes even encourage, such anti-patterns. Whilst
might be the best known, there are three other contenders for the worst anti-pattern of all: not writing automated tests,
and object-orientated (OO) inheritance. It’s the last that is the topic of this post. Continue reading “Inheritance: just stop using it already!”
This post is in reaction to an article on the American publication website, The Atlantic, entitled “Programmers: Stop Calling Yourselves Engineers”
. That article itself paints a rather silly, rose-tinted, picture of engineers and tries to argue that programmers don’t make the grade. This post isn’t (just) an attack on that article; it is an exploration of the various terms used to describe programmers and whether any are fit-for-purpose as a unifying term to describe those who code? Continue reading “Should programmers really stop calling themselves Software Engineers?”
interface has numerous extension methods associated with it, including a number that return a single element if a match occurs, or return the default value for the type if that fails:
. These methods create two code smells due to the nature of .NET’s type system. As of version 1.5.0, Succinc<T> offers alternatives to these methods that overcome those smells. Continue reading “Using Succinc<T> to overcome IEnumerable code smells”
In my last post
, I examined whether or not the Service Locator is an anti-pattern. The conclusion was that it isn’t. Instead it’s a code smell that all too often causes another anti-pattern to occur: hindering easy testing.
One of the reasons cited for why it’s only a code smell is due to edge cases where a service locator can be used internally within an assembly as an implementation detail that doesn’t affect testing. It’s natural to ask what such a test-friendly service locator might look like. The Visual Studio/MSBuild and .NET framework combination supplies such a locator:
.resx files and the
Continue reading “An example of a benign Service Locator”
Recently, I’ve been reading a number of articles arguing whether the Service Locator pattern is in fact an anti-pattern. On one side of the fence, there are those that argue yes, such as Service Locator is an Anti-Pattern
by Mark Seemann and Service Locator is Indeed an Anti-pattern
by Nick Hodges. There are those that argue the opposite though, such as Service locator is not an anti pattern
, by Jonas Gauffin. Continue reading “Is the Service Locator an anti-pattern?”
If you live in the world of OO languages, you likely fall into one of two categories:
- You are still happily using inheritance,
switch statements, nested
if/else collections, have methods that are hundreds of lines long etc. You possibly haven’t heard of TDD or DI. There’s a very good chance that, if this is the case, you’ll likely never see this post as you likely do not read blogs by other developers.
- You do read around, you are aware of why inheritance,
switch, deeply nested and long code blocks are frowned upon by the well-informed. You are at least aware of TDD, even if you haven’t quite started using it yet. Also, you are likely aware of the growing excitement around functional languages and perhaps look on with envy at some of their features. If this is you, you possibly already use SHOF’s without knowing it.
Continue reading “Do you SHOF? Higher order functions in OO languages”
One of the last posts I wrote before disappearing off the face of this blog for nearly two years was “Are IoC Containers a case of ‘The Emperor’s New Clothes’?
” there were two main points that I was exploring in this article that bugged me at the time:
- All too often, people seem to come up with dreadful implementations of IoC that either exposed all of their application to the container or they used some sort of “God object” container to handle injection into every part of the application.
- The way to avoid the above problem was given the rather insulting term “Poor Man’s DI”, which was unhelpful as it naturally discouraged those learning about DI from using it.
Continue reading “Poor man’s DI is dead; long live Pure DI”
To certain extent, the title of this post is a little dishonest: it’s not really the first time I’ve introduced Succinc<T> on this blog. I first mentioned it over two years ago. To explain the title therefore, some history is required.
During early 2013, I was indulging myself in a “thought experiment” language: Lapsang. One such thought experiment was around the idea of whether a language could sensibly support the concept of not throwing exceptions for petty, unexceptional, reasons. Continue reading “Introducing Succinc<T> — functional additions to C#”
Two years ago (almost), I stopped posting to my blog. Two years ago (almost) I took the opportunity to switch roles within the company I worked in at the time from developer to development manager. The two events are of course linked. It was a big move for me. I’d previously been a team leader; I’d previously had responsibilities for managing groups of people, but each time I’d carried on spend at least some of my time developing code. This role was different though. This role was 100% management. Coding became a thing of the past. There was lots of new skills to learn: people management; product management; project management; finance; and – with hindsight the most important skill learned – expectation management of commercial desires of the company.
So why didn’t I blog about these new discoveries? To put it simply, I was unsure about what was appropriate to post; how to talk of what I was learning without compromising the commercial confidence of the company. I couldn’t post about the negatives and the positives always seemed almost mundane and hardly interesting reading for others. So time passed and the blog died a slow death… Continue reading “I’m back!”
I don’t use IoC containers. Many of the best developers I know swear by them. More, three incredible people who have taught me so much over the last few years – Shaun Smith
and Till Schneidereit
– even developed their own, very popular, IoC container: RobotLegs
. Yet I don’t use IoC containers. I’m a big fan of dependency injection and a passionate advocate for the return of the death penalty for the singleton and service locator patterns. Yet I still don’t use IoC containers. Is the reason I don’t use them because IoC containers are a case of “the Emperor’s new clothes”? Continue reading “Are IoC containers a case of “the Emperor’s new clothes”?”
Do you have a compatible Apple device, but are unsure whether to install Apple’s latest OS on it? If so, I’ve created a handy flowchart to help you decide. Continue reading “To upgrade or not to upgrade (to iOS7)?”