Lachlan B's Blog

How I could have saved Carlo from HumanKode lots of money

You might have read the story how Carlo lost $6,500 thanks to a bug in Visual Studio GitHub's plugin.

It turns out that the issue was caused by a checkbox not working.

So what was the problem? The issue was that it's super-easy to accidently completely break a WPF control when you're just trying to change it's color. Why? Because if you want to change it, you have to completely override the entire control. So you end up having to copy and paste the code for the entire control, and then change what you need. So to fix the issue for Carlo they had to fetch the right control template code and then put it back in. But really, that's just a bandaid over a much, much more complicated problem.

I came across this problem in 2014 and suggested a (horrible) workaround. As you can see it's not simple, but it's better than nothing.


Read More ->

Async, await and ASP.NET

Today I came across a brilliant explanation of c#'s await keyword. I've been trying to figure it out for a couple of weeks now and every time I read it the explanation gets too complicated too quickly. The essential problem is as follows:


Marking a method as Async doesn't make it Asynchronous


And therein lies the confusion.

(BTW I'm not sure which genius came up with this. Probably the same person who came up with "Visual Studio Online" - because.. you know.. it's not actually an online version of visual studio.)

So anyway marking a method as async doesn't make it asynchronous. What the heck does it do?


Async releases the thread from the server pool


Huh? Well, normally each request in IIS takes up a thread. While IIS has a bewildering number of performance tuning options it essentially has a fixed number of threads available to process simultaneous requests. Each request uses a thread. So normally, the maximum number of simultaneous requests possible comes down to the maximum number of threads. So, if suddenly 1000 users hit your app at the same time, the 1001st user's request is going to be put into a queue, and they will have to wait. Now if your queue size is say 5000, and you then suddenly get 5000 more users h...
Read More ->

DDD Conference 2015 wrap up

ddd conference

Two weeks ago I spoke at the DDD Melbourne conference on the topic "How to be the best developer in the world". The talk went ok, and so I have turned it into an epic blog post:

How to be the best developer in the world

Big thanks to Troy Hunt for his super-helpful Speaker Style Bingo article, and also mad props to Lars Klint for his willingness to give me a go!


Read More ->

How to be the best developer in the world

To kick off this blog, I think that I need to state the following:

I am not the best developer in the world.

I know a lot of the things that you need to learn in order to become a great developer, but just knowing these things doesn’t make it happen. Head knowledge is good, but that’s the easy part. Putting it all into practice… that’s what’s difficult. I'm still a work in progress!

So in order to become the best developer in the world you're going to have to ask yourself a pretty serious question:

"what level am I at?"

To work this out, you might compare yourself to a couple of job ads. If you start poking around the internet for software developer jobs, you’ll find things like this:




Notice how they advertise "3 years XP"? Unlike other crafts, software development does not have a well-defined methodology for working out how good a programmer is. All we go by is “years of experience” which is a pretty bad methodology - you can sit on your bum for five years, not learn anything, and you're suddenly a mid-level developer. It doesn't really mean anything. Instead of years of experience, what we need to know is competency.

Have you seen the programmers competency matrix? It's a great list, but I feel like it's missing a bunch of things.

A...
Read More ->

Securing your pc after online abuse

So you're the target of online abuse? You need to secure yourself from being hacked. Here's what you need to do immediately:

  • Enable two factor authentication for every account that you can - especially your main email account. Your main email account can be used to get access to all of your other accounts via a password reset, so it's very important that you protect it. You need to enabled it for your google account (called "two-step") and also for you facebook account (called "login approvals"), twitter (called "login verification"), banking, and any online account that supports it (as of writing, instagram doesn't).
  • Put a lock code onto your mobile so that if you lose it, people can’t access your accounts.
  • Back everything up - onto a USB drive, AND use an online service (I have heard that BackBlaze is good).
...
Read More ->

Speaking at DDD Melbourne 2015

Next weekend I'll be talking at DDD Melbourne on "How to be the best programmer in the word". This will be my first full length talk at a conference so I'm excited, nervous and happy all at the same time!

Trying to cover such a massive topic in 45 minutes is quite ambitious... to say the least. Obviously I won't be able to cover anything in any substantial detail, but I can hopefully point some people towards the right direction in where their next steps should be to improve their skills.

In the spirit of trying to be as organised as possible here's all of the links that I will mention in my talk:

And the most ...
Read More ->

An android app for Timor Leste

For the past couple of weeks I have been developing a mobile app for Livru Timor in association with Rhok Australia.

The basic problem that we are trying to solve is translating some childrens books into a bunch of different languages. Sounds simple right? Well the main issue is that we don't really know what these languages are! We don't know what a lot of their words are, and we don't really know where they are spoken. In 2015.

So why don't we have a simple android app where you can go to a local village and ask a bunch of people what their words are for things? We could even record them saying their words. Then we could collate the data and send it back to a server in Melbourne and figure it all out... and translate a bunch of these childrens books to their native languages and the kids will have a much higher chance of learning how to read and write! Cool huh?

Oh and BTW, the android phones that they have in Timor Leste are basic. Very basic. Most of them don't even have data. You need to be able to store all of that information offline, and then at some stage be able to upload it to a server once we've on a (somewhat) more reliable wifi network :)
...
Read More ->

What programming concepts I should master to have a deep understanding of my craft?

So you’ve been working as a programmer for a couple of years, and you want to become a good programmer. But not just a good programmer, you want to be a GREAT programmer. You want to paint with ALL the colors. Hell, you want to paint with all the dimensions. You want to be the GURU of programming – not just some nerd that’s stuck in corner that knows every namespace in the .NET API and can punch out a website in a day – you want to be a Michelangelo. A Picasso. Programming isn’t a science, it’s an art. You want to be respected.

Boy that’s a big ask.

So how do you get started?

By now you’ve hopefully realized that what makes good programmers great isn’t necessarily their technical skills. Your technical skills can be AWESOME, but if you don’t know what your customer wants, they amount to diddly squat. Of course if you know what your customer wants but don’t have the technical skills to back it up, you’re also up the creek. So what are the technical things you want to learn?

* How to write “DRY” code. DRY stands for “Don’t Repeat Yourself”. Copy and paste coders are not real coders. If you find yourself writing the same (or similar enough) lines of code more than once, it needs to be cleaned up so that you don’t have duplicate code all over the place. This will actually keep your codebase smaller, easier to maintain and reduce your bug count. People call this refactoring and it’s a daily part of ou...
Read More ->

How to know you've been coding too long in .NET

  1. Ever called .First() instead of FirstOrDefaut() and had it throw an exception instead of what any sane person would expect and return null?

  2. Ever expected For Each on a null collection to work the same as an empty collection... (I HATE, HATE THIS)

  3. Ever called .Hours() instead of .TotalHours() on a TimeSpan object?

  4. Ever called .Append() or .Sort or .AddHours() or .Replace() .. and it didn't do anything? But then you realise that it RETURNS the value?

  5. Have you ever forgotten to specify the correct app pool in IIS and accidently run against the incorrect framework?

  6. Have you ever developed against IIS Express and discovered the world of difference with your production IIS server?

  7. Stupid, stupid American mm/dd/yyyy format!! Have you ever entered a date of 1/12/2015 and it worked great, then you try 1/13/2015 and it FAILS? (Every single developer in Australia and in the UK hates datetime parsing, because no matter what you do, your server, or your code, or your database server, or your model binding in MVC, or who knows what else... will sometimes decide for no apparent reason that it's going to parse your dates in the (stupid) US format.)

  8. Talking about MVC, did you know that a json object that has a property set to 0 or 1, when bound to a .NET object with a boolean property, using the s...
    Read More ->

An ASP.NET bug from 1973

Today, I was coding an ASP.NET 4.5 REST api using WebApi 2, and was caught out by a problem caused by a technical decision made forty two years ago.

I think I need to repeat that again. FORTY TWO years ago. (Yes, it's spelt f-o-r-t-y, not f-o-u-r-t-y, thanks anonymous pedantic reader!)

1973! The year when Aerosmith released their debut album! The year Elvis Presley's concert in Hawaii had more watchers than the moon landing!

Apparently, in ASP.NET, having a URL end in "AUX" causes it to throw a 404 error.

This might happen if you were building a RESTful web service that validated country codes. For example, you might make a request to this URL

http://myserver.com/ValidateCountryCode/NZ

Which would return "New Zealand".

Or maybe you're testing Australia:

http://myserver.com/ValidateCountryCode/AU

And then of course, you want to test your web service to see what would happen if you passed through invalid country code:

http://myserver.com/ValidateCountryCode/AUx

Which gives you a 404 error, thanks to CP/M, an operating system coded in 1973.

What a conundrum! Do I fix it or apply the patch?

...
Read More ->