Lachlan B's Blog

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.


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).

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 ...

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 :)

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...

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...

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

Which would return "New Zealand".

Or maybe you're testing Australia:

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

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?


Succeeding at every job interview

The HR boss of google, Laszlo Bock, is spruiking his new "Work Rules!" book. As part of the promotion campaign he has written a very popular linkedin post explaining "How to win every interview with these 6 steps".

Now apart from the obvious clickbaity title, which I'm prepared to give a little bit of leeway, I would like to point out just how wrong he is.

Normally I would leave these kind of clickbaity promotional marketing articles alone and treat them with the contempt they deserve, but in this case, it's coming from the HR manager of google, who you assume would know better. I also feel that this type of article rather is also extremely demotivating to the job seeker, and Mr Bock should know better.

So to start with the positive aspects of this article. In general, these tips will probably help differentiate you from some of the competition. Doing your research, having a pre-prepared list of questions and answers are all a smart way to prepare. Rehearsing your answers is a great idea.

But will it help you win every interview?


You know why?

  • People are unpredictable. They might have gone for you yesterday, but today, they are extra tired. Yesterday they wanted to take a gamble on someone like you, but today, they just aren't feeling up to depending their decision.

  • Interviewers are biased. To put ...

Generating barcodes with zen barcode generator

Someone asked me on Sunday if it would be possible to generate a PDF that had a barcode in it. I haven't generated a "normal" boring 2D barcode before, so I thought I'd give it a crack. I find a library named Barcode Rendering Framework, downloaded it, looked for the documentation on how to use it... and there isn't any.

I mean, there is literally none. The answer is "look at the code samples". This attitude drives me up the wall. It would seriously take the developer 10 minutes to write a good document explaining how the thing works and how to use it. But can they be bothered? Nope. So after much head scratching and stuffing around I figured it out.

private string getBarcode(int type)
	BarcodeSymbology s = BarcodeSymbology.Code39C;
	BarcodeDraw drawObject = BarcodeDrawFactory.GetSymbology(s);
	var metrics = drawObject.GetDefaultMetrics(60);
	metrics.Scale = 2;
	var barcodeImage = drawObject.Draw("1234123132", metrics);

	using (MemoryStream ms = new MemoryStream())
	    barcodeImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
	    byte[] imageBytes = ms.ToArray();

	    return Convert.ToBase64String(imageBytes);

And then to embed it on the page I just use an image tag:

 <img src="data:image/png;base64,bytearraydatagoeshere" /> 

Which produces th...

Moving from classic ASP to MVC5

So the past few weeks I've been re-writing my website. Previously it was written in Classic ASP (yes, you read that right) and it was running off a Microsoft Access database. Yes, you read that right too.

The code has served me well since I launched in 2006, and can I point out, that was NINE years ago. I have to salute classic ASP for doing a pretty bang up job. The site rarely went down, it was never hacked (apart from a mountain of comment spam) and it was all-in-all, pretty good fun.

But the past couple of years has seen a huge improvement in website coding. It's all so much easier and more fun now, so I figured I might as well rewrite it in ASP.NET and move it to MVC. So here's the full stack of technologies:

  • Bootstrap for the front end - fantastic library once you get your head around it

  • JQuery for the little ajaxed archive box over to the right

  • ASP.NET MVC4 for the back end

  • Entity framework for talking to the DB

  • SQL Server for the DB

The whole thing was coded using Visual Studio community edition and SQL Server express. Half was written on my desktop, and the other half was written on my MacBook air running a windows 7 VM using Parallels - a process that ran surprisingly well. I synced the code between the two machines using Git Gui, another process that...