A Humbly Arrogant Blog

Posts about software development

Don't return null

If you’re programming in an object orientated language that supports exceptions you should never return null in a method that returns an object. Most object orientated languages support exceptions. Exceptions give us an extremely expressive way to represent error conditions. We throw an exception and the program bails out of where it is and then goes to the error handling section. We can create custom exceptions to express exactly what sort of error occured. ... Read more

My Opinion on testing code with 3rd party API calls

I’ve recently had a discussion about how I would go about testing code that makes calls to a remote third party API. It seems my way of thinking isn’t the same as most others. So I figured I would write out my thoughts and explanation behind why I would go for this route. Others peoples approach So first I want to explain other peoples thought patterns seem to be. It goes like: ... Read more

How I use Dependency Injection

I’ve been thinking about dependency injection a lot recently and the best way to do it in a clean manner. I recently changed how I was injecting some dependencies, at code review I was asked why. So I figured I would write a blog post fully stating my current views on how to implement Dependency Injection. There are three main ways of injecting a single dependency, as well as what I would consider two ways of injecting multiple dependencies these are also known as patterns. ... Read more

Revel : How to use Drone.io for testing

Being a lover of testing, continuous intergration, and cloud services. I wanted to be able to get a build of status of a Revel framework app I’m working on. Since Revel uses it’s own command to run and build applications the standard way of doing a build for Golang are out. I wanted to use Drone.io instead of travis so if I wanted to make it private I could without paying a lot. ... Read more

Revel : Force template format

So in Revel you can have your template in several different formats: html, json, xml, or txt. This is super awesome. As it allows you to send the same data and display different formats - Obivously. It also determines what template to use based on the http request headers that have been sent. So if your request sends that it accepts application/xml it’ll use xml and if you request says application/json it uses json. ... Read more