Pramatr Blog

A collection of articles from pramatr.com on technology, security, software and anything we find interesting

  • Subscribe

  • Disclaimer

    The opinions expressed here are my own and are not necessarily shared by my employer, any other organization, or any other individual. Any trademarked names or labels used in this blog remain the property of their respective trademark owners. No guarantees are made regarding the accuracy or usefulness of content on this blog, though every effort is made to be accurate.
  • Meta

Unit Test Assertions: What Could Possibly Go Wrong?

Posted by pramatr on 6th November 2008

Lots of my development effort is taken up writing unit tests. These tests form a nice warm security blanket for the code that I’ve developed. If the code is broken, typically these tests are the first feedback that something is wrong. Although some people fear the little red bar, it’s become a common part of development. So with this in mind, it’s vitally important that when a test fails, is crystal clear what really went wrong.

Over the past few weeks, I’ve been reading xUnit Test Patterns (review to follow in another post), which covers making tests easier to write, understand and maintain. One important issue it discusses, is the use of assertion methods.

Assertions are a fundamental part of writing unit tests, and are typically very simple to use. Within each test, the expected outcome is expressed using assertions, each of which is boolean expression. The assertion should evaluate to true, so if the evaluation of the assertion instead returns false, the test will be failed. JUnit provides the Assert class to handle various types of common assertion. Although Assert provides a number of very simple methods, I’ve seen these frequently used inappropriately, causing unit test failures to be unnecessarily difficult to track down.
Read the rest of this entry »

Tags: , , , , , , , , ,
Posted in Opinion, Testing | Comments

Parleys.com: My New Favourite Site

Posted by pramatr on 18th October 2008

parleys-logoFor the past few months, I’ve been spending most of my lunch breaks viewing the plethora of content available on Parleys. I first heard about Parleys courtesy of Marten Deinum, during a conversation on Spring Forum. Back then it seemed to be a well kept secret, but according to it’s website, 45,000+ people have now visited the site.

For those of you who haven’t had the pleasure of visiting Parleys and don’t know what it is, the home page describes it as:

Parleys.com is a new BeJUG initiative where the different recorded talks from JavaPolis, BeJUG, SpringOne, JaZoon, JavaZone and EclipseCon (and hopefully others in the future) get published on a regular basis.

The Parleys.com site wants to become the premier Java e-learning site where you can listen and subscribe to many Java related podcasts or view the flash talks, hopefully all resulting in improving your Java skills.

parleys-presentation-list

There’s a wide array of presentations available (over 100 at last count), so there should be something there to interest you. Each presentation gives you a handy overview of the content, the running time and also the votes that have been cast. All of these together, make it very easy to choose something to fill your lunch break.

parleys-presentation-overview

The presentations provide audio, video and also slides to accompany it. It’s great to be able to leave the presentation going in the background whilst I’m do something else. If I really have nothing to do, it’s great to be able to view the additional content the slides provide. One feature I’ve found invaluable however, is the ability to skip through the agenda. When you have to get back to work, it’s so nice to be able to carry on watching from where you left off when you get home.

parleys-presentation-contents

If you haven’t already used Parleys, I would thoroughly recommend a visit. I’ve found Parleys to been an invaluable tool for learning about new technologies and techniques. Over the past few months, I’ve seen a large number of presentations on topics that I previously knew virtually nothing about. There are typically new presentations added at least every couple of weeks, so I’m looking forward to seeing what content is added next. And lastly don’t forget to vote for the presentations, it’s great to know what other people did or didn’t enjoy!

Tags: , , , , ,
Posted in Opinion | Comments

Yes You Are Making Changes, But That Doesn't Make It Refactoring!

Posted by pramatr on 26th September 2008

There are some words in software development that overtime lose all meaning. The more these words are used, and importantly, the more they are used out of context, the more the original meaning is lost. It becomes just one of those words that is fitted into a conversation without even thinking about it. One word that often suffers from this problem is refactoring.

The term Refactoring is widely used throughout software development. Martin Flower is one of the primary documenters of refactoring, and popularised it in his seminal book, Refactoring: Improving the Design of Existing Code. Many people who use the word refactoring however, have never heard of the book and more importantly don’t have a clear understanding of what refactoring actually is.

Refactoring is described as; a disciplined approach for modifying code without changing it’s externally observable behavior. This approach is focused around applying small changes to the code, each of which maintains the existing behaviour. By incrementally applying a number of refactorings, the code can be modified in a measured and controlled manner. Extreme programming embraces this approach with a rule named refactor mercilessly.

Read the rest of this entry »

Tags: , , , , ,
Posted in Development, Opinion, Refactoring | Comments

Structured Approaches To Improving Code Quality

Posted by pramatr on 17th August 2008

Over the past few years, I’ve worked on numerous projects that have grown very quickly but have lacked a structured approach to development. The code is grown somewhat organically, being used in ways never imagined and bent into shapes it was never supposed to make. In the very worst cases, it ended up with Spaghetti Code that is self-obfuscating and unintelligible (even to the original author).

To help prevent this situation, teams need to embrace processes to help introduce structure and discipline to software development. This can be daunting to some teams at first, but it’s a far more productive and appealing than a team that is constantly under-pressure with various fire-fighting activities.

Kent Beck has said previously that he is not a great programmer but just a pretty good programmer with great habits. I’m a firm believer in that statement, and I think that any team that doesn’t try to develop those habits is starting from a weakened position. I’ve worked on both projects that embraced change and tried to improve their development process and also those that didn’t. I would sooner work on the former type of project every time.

With that in mind, there are very simple changes you can make to a project to help foster better habits. None of these techniques is new or groundbreaking (at least anymore), but I am still amazed at the number of projects that still don’t embrace them. There is plenty of information on these techniques out there, so there is no excuse if you want to do some more reading.
Read the rest of this entry »

Tags: , , , , , , , , , , , , , ,
Posted in Development, Opinion, Refactoring, Testing | Comments