Being a professional software engineer

The Wild West

In some ways we are still in the wild west of software development, professionally (despite the practice being about 70 years old), consider the Industrial Revolution which ran for about 80 to 100 years, ending in the mid to late 1800s. It wasn’t until the end of that era that professional engineering bodies appeared and it was the turn of the 19th Century that, in Great Britain, we began to develop engineering standards for consistency and quality. That’s almost 200 years from when Newcomen’s atmospheric engine first started to use steam to generate the mechanical work to power the revolution.

As we live through the Digital Revolution and Information Age today we are in a similar place, professionally, as mechanical engineering was at the turn of the last century. My hope is that the coming decades will see software engineering attaining the same stature as other engineering disciplines so that we can deliver software as professional engineers, but first that will require us to act more professionally.

Continue reading

Unit Test Patterns: The Domain Test Values Class

On my latest Java project, my colleagues and I are keen to improve the readability of test classes. We’ve chosen to use Mockito and Hamcrest because of their natural language approach to mocking and assertions, but on their own they can’t always convey the meaning of values used in a test.

To overcome this, we use a pattern which I’ll call the “Domain Test Values Class”,  the purpose of which is to provide values used in the testing of a domain in a way which improves understanding of test code by increasing readability and adding meaning to values.

Continue reading

Redirecting to .com (without confusing CloudFoundry…)

It’s a two-for-one today – a “gotcha” and a “how to” all rolled into one, this time about redirecting in a Grails filter.

Much like my favicon woes my initial attempt to redirect to a primary domain (a .com without the “www” prefix) had some unexpected consequences when deployed to a live server on CloudFoundry – I started getting warnings that my site had gone down!

In this post I’ll hopefully save you the panic of CloudFoundry telling you that your site’s not responding when you try to rationalise your domain names!

Continue reading

When localhost is not the same as 127.0.0.1 a MySQL Connection Gotcha

Setting up MySQL connection pooling has been standard stuff in server-side apps for as long as I’ve been writing them, so I was at a loss when, every 5 days or so, my newly deployed app died with this exception:

Exception in thread "main" 
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: 
Communications link failure

Last packet sent to the server was 0 ms ago.

Continue reading

Spring Secutiry (ACEGI) Plugin and Favicon Permissions

Here’s a quick gotcha for you. You set up a favicon in the root of your web app, as is the convention, and when you log in you are redirected to a picture of your favicon or you are asked to download it… Weird.

Odds on you’ve installed the Spring Security plugin and forgotten to give permission to the favicon file in the root and the result is that on login Spring Security redirects you to the first restricted item that was requested by the browser – the favicon.

The solution? Easy, set the favicon path to IS_AUTHENTICATED_ANONYMOUSLY in your SecurityConfig.groovy (or database):

controllerAnnotationStaticRules = [
    ...
    '/favicon.ico' : ['IS_AUTHENTICATED_ANONYMOUSLY'],
    ...
]