Apr
11
2010
Why should you adopt Test Driven Development? The answer is actually more complex than many people think.
Of course we all want to have fully tested code to ensure that the code operates as expected. We also want to ensure that any new features do not break existing functionality (regressions), but what other reasons are there?
Continue reading
no comments | tags: Add new tag, JUnit, TDD, test driven, testability, unit testing | posted in Software Architecture, Software Development, Technology
Apr
10
2010
Web programmers know that they shouldn’t go writing JSPs with the Context Path hard coded in them.
If you do the following:
<a href="/MyApp/path/to/controller/home.htm> Home </a>
You’ll notice that as soon as you decide to deploy your web application using a different name than “MyApp” then none of your links will work anymore.
To avoid this you need to get the context path from the HttpRequest object as follows:
<a href="<%=request.getContextPath() %>/path/to/controller/home.htm>
Home
</a>
or by using a JSTL tag:
<a href="<c:url value="/path/to/controller/home.htm"/>"> Home </a>
What happens when you are rendering HTML in your Java code and you don’t have access to a HttpRequest object for whatever reason?
Continue reading
no comments | tags: Java, servlet, web | posted in Web Applications
Nov
16
2009

A couple of months ago I finished the first version of JTestConnect. It is a tool for supporting development teams with their unit test strategies.
You can annotate your interfaces/classes with annotations describing how the object should be tested. The tool then sits in the build process and can interrupt a build if test classes/methods are missing.
Ideally, this would be added to a Continuous Integration build system to enforce test coverage of important classes.
A more detailed description of what it does can be found on the project home page.
no comments | tags: Java, TDD, test driven, unit testing | posted in Software Architecture, Technology
Nov
16
2009
How can you detect if your browser supports HTML5 features in javascript? Here’s how:
function isHTML5CanvasSupported() {
return (typeof HTMLCanvasElement != 'undefined');
}
function isHTML5VideoSupported() {
return (typeof HTMLVideoElement != 'undefined');
}
function isHTMLClientSideDBSupported() {
return (window.openDatabase);
}
Have fun!
no comments | tags: html5, javascript | posted in Technology, Uncategorized, Web Applications
Mar
6
2009
There are two competing philosophies with regard to unit testing strategies; state based testing and behavior based testing. In state based testing we configure a starting state, execute a test method, and then examine the resultant state/returned result. In behavior driven testing we ensure that our test object collaborates with its dependencies in an expected way.
Continue reading
2 comments | tags: EasyMock, Java, JUnit, Testing, Web Applications | posted in Software Architecture, Technology, Uncategorized, Web Applications
Feb
5
2009

Random Numbers
2 comments | tags: cats, GIMP, pixel art, random numbers | posted in Art, Fun, Technology
Jan
30
2009
Using an anaemic domain model is often considered an anti-pattern. The reason for this is that it encourages coders to duplicate code needlessly. This is going to be a fairly short (and fairly trivial) post explaining one of the mechanisms by which this occurs (with an example). The mechanism can be avoided with careful planning and strict coding discipline but it is quite a lot easier to apply good encapsulation. The difficulty with avoiding the pit falls of an anaemic domain increases exponentially as more team members work on the project.
None of this will be new for anybody with a moderate understanding of OOP, but it is interesting to see how a small number of fairly innocent steps can lead to a real mess.
Continue reading
5 comments | tags: Anaemic Domain Model, Code Smells, Domain Driven Design, Rich Domain Model, Rotting Code, Software Architecture | posted in Software Architecture, Spring, Technology, Web Applications
Jan
1
2009
Instead of listening to music or watching episodes of your favorite TV show on your video enabled mp3 player, why not head over to MIT OpenCourseWare page and download some video lectures. There are lots of pretty high quality videos taken from inside a lecture theater with a very wide range of subjects. You could learn something the next time you are commuting to work.
Hopefully your screen will have a high enough resolution to read the blackboard.
no comments | tags: learning, MIT OpenCourseWare, mp3, video | posted in Fun, Technology
Dec
31
2008
I’ve been playing around with Domain Driven Design (DDD) and trying to write a small web application without implementing an anemic domain model. I have found that it is more difficult than it ought to be and I want to share some of my experiences.
An anaemic domain is something that happens in an enterprise application when your domain objects don’t really contain any real logic. Instead the logic nearly all resides in a secondary “service” component. This is an example of badly encapsulated code and will lead to messy, difficult to maintain applications.
Continue reading
3 comments | tags: Anaemic Domain Model, AOP, AspectJ, Domain Driven Design, Hibernate, Java, Spring, Web Applications | posted in Spring, Technology, Web Applications
Jun
9
2008
Asirra is a serious piece of Microsoft research, and is a highly effective tool for preventing spam bots from filling up your blog with adverts.
Spammers are becoming increasingly sophisticated and are able to bypass many captcha’s. My own blog has been inundated with spam despite asking users to answer maths questions to validate their comments. Even image based captchas can be fooled and they now serve only to slow the spam down….slightly.
Asirra interests me greatly because it is a symbiosis of two projects. Their aims are quite different, but they are able to collaborate for a common gain. When a user wishes to add a comment, they are asked to identify a series of photos and to categorise them as either a cat or a dog photo. The photos come from an animal adoption web site with a large image database and receive free advertising (perhaps when you write your comments you’ll decide to adopt one of the animals in the pictures).
Spam bots can perform image analysis to a quite sophisticated level it seems, able to read obfuscated text. Lets see how the fare analysing pictures of small furry creatures.
A Wordpress plugin is also available, and it was pretty easy to install. I will let you all know in a few weeks how the experiment goes, and if I receive any spam.
1 comment | tags: antispam, cats, dogs | posted in Fun, Technology