Software Engineering categories
using over lambda
Let’s talk about these two patterns: public void GetSomethingDone() { var metaData = "Some Sort of Metadata for timing"; var result = DoTimedWork(metaData, () => { MyResult resul; //Some other complicated work/method-call happens here return result; }); //either uses or returns result here } public T …
Fork off with your branches
The nice thing about git is that branches are cheap and you can create many and varied branches for every little fix, format or feature. The annoying thing about GitHub is that every user creates many many many branches. One of my pet peeves at the moment is a large number of branches on our upstream repository. That …
Manage your hosts entries better
If you are working with a lot of sites in IIS then you will be familiar with the hosts file on your computer. %SystemRoot%\System32\drivers\etc\hosts, usually found in C:\Windows\System32\drivers\etc\hosts. This file acts as a DNS mapping table used by your computer. As a developer, you will often want to tinker with …
A couple of debugging tips
I had an idea of something I wanted to post, but a quick google turns up I posted it 6 months ago, so here are some debugging tips. Console Break So you are writing a console app? Cool. Want to see the output? Of course, you do. But when you run it, the app pops up then disappears really quickly right? No? Have you a …
On Passion in IT
Some people have a natural gift to be able to learn. They can pick up any subject and by putting in hard work they can get good at it. Some people have a natural interest in a specific subject, and these people enjoy the process of learning and don’t find the work being put in as ‘hard’, but instead it is fun. They too …
Treat Warnings As Errors with this one weird PowerShell Script...
There is this great feature in Visual Studio that lets you really dial up the quality of your code. It has been there forever it seems, but very few people use it. The compiler spits out errors, which stop your app compiling. You fix your errors and move on. But the compiler also spits out a lot of warnings too. And …
The new 80/60 rule for testing
I was listening to a presentation on testing, and the question on coverage came up. I was asked my opinion, and this interesting thought occurred to me. So I tweeted: New Rule: At least 80% coverage on 60% of the app. 70% of the time, it works everytime. Mark Clearwater (me) So what do I mean by this? Well basically, …
On gitversioning subdirectories
We have lots of NuGet. Every time we build, we publish a new version. but every build does not change the source code of the code in that version. wouldn’t it be nice if we could detect that the subdirectory hasn’t changed and so has the same version it did last time we built it? We use gitversion, so we …
On fixing problems in existing solutions
A builder came around the other day to fix the shelf under the sink. We had a leaking tap that over time had been dripping down onto the shelf and the boards had ended up in an awful state. From my perspective, we just simply needed to rip it out and put a new one in. Luckily, the builder was an expert and explained to …
Make me a sandwich
A lesson in powershell. I typed this: > iisreset Which responded with this: Access denied, you must be an administrator of the remote computer to use this command. Either have your account added to the administrator local group of the remote computer or to the domain administrator global group. So I typed this: > …
Pets vs Cattle
There is this concept that has been floating around for a while which says you should treat your servers as cattle, not pets. I came across another version of this analogy that I wanted to post, since it doesn’t seem to have been recorded anywhere but has been mentioned in presentations. But before I get to that, …
Visual Studio 2015 vs Visual Studio 2013
I’ve been running some numbers over our solution to try and make things more efficient. While I was at it, I figured I would put 2013 head to head with 2015. The main test I ran was to take a solution open in Visual Studio and make sure it builds. I then ran Clean Solution. Using a stopwatch (so accuracy +- …
ExternalAnnotations, or how to not depend on jetbrains.annotations.dll
There is some great static analysis stuff that ReSharper does for you. Specifically around nullability, purity and usage of your code. From their Code Annotations page in Visual Studio: ReSharper Annotations help reduce false positive warnings, explicitly declare purity and nullability in your code, deal with implicit …
Using C# 5.0 with Visual Studio 2015
Visual Studio 2015 is out and brings us the new C# 6 language features. We also have the new .Net 4.6 Runtime. But what does that mean? Well, the framework version and language version are two separate concerns. You can practically pick any framework, with any language, and it will work. This means that If you want to …
MethodImplAttribute and MethodImplOptions
I’ve been following some C development going on in the community, and discussion around memory management and optimisations lead me to start thinking about how they might be emulated in a C# application. Slight Digression Now I know that you have to prioritise Correctness, Performance, Readability, and that C# by …
Another layer of indirection
There is a ‘great’ quote in Software development about indirection that goes like this: Any problem can be solved by adding another layer of indirection. David Wheeler The follow up to this, of course, is to end it with the following: …except for the problem of too many layers of indirection. Kevlin …
The Service Locator base class anti-pattern
Something I have seen a lot of over the last few years is a lot of service location, particularly in base classes, particularly in Controllers. But not limited to there, it can happen anywhere we see base classes. Short rant about inheritance The longer I do this, the more I find that base classes are not meant to be …
Html anchors, links, and css
As part of reskinning my blog, I have had to rethink my menu links and CSS. I discovered something interesting that I hadn’t really thought about before. But let’s start with a lesson that got me to where I made that realisation. LVHA I recall a time at uni where I was learning about CSS. The phrase Love, …
public, private & new: C# visibility scope explained
I wanted to go over the visibility modifiers in C#. There are a few, it’s not as simple as just public or private. Let’s go through some scenarios and get our heads around what we can use, when and why. I couldn’t think of a good term to group the concepts of methods, constructors, and classes, so I …
More small classes
Its a pretty common rule of thumb to avoid monoliths and write more small classes. Think about the solid principles. Single responsibility per class. This implies less in it. Smaller. Open for extension closed for modification. Take out the things that will change. Smaller. Liskov substitution principle says …