background preloader

IT stuff

Facebook Twitter

Contents. Learn Flex in a week.

Quality

Games. Addison-Wesley Signature series. Books by Martin Fowler. Joe Walnes, Flexible JUnit assertions with assertThat() Flexible JUnit assertions with assertThat() Over time I've found I end up with a gazillion permutation of assertion methods in JUnit: assertEquals, assertNotEquals, assertStringContains, assertArraysEqual, assertInRange, assertIn, etc. Here's a nicer way. jMock contains a constraint library for specifying precise expectations on mocks that can be reused in your own assertion method (and that's the last time I'm going to mention mocks today, I promise - despite the frequent references to the jMock library). By making a simple JUnit assertion method that takes a Constraint , it provides a replacement for all the other assert methods.

I call mine assertThat() because I think it reads well. Combined with the jMock syntactic sugar, you can use it like this: Okay, that's nice but nothing radical. Combining constraints Constraints can be chained making it possible to combine them in different permutations. AssertThat(something, not(eq("Hello"))); assertThat(something, not(contains("Cheese"))); else.

Database

Scrum. JavaScript Programming Patterns. JavaScript is meant to be used to add behaviour to a website, might it be for form validation or for more complex operations like drag & drop functionality or performing asynchronous requests to the webserver (aka Ajax). During the past few years, JavaScript libraries became increasingly popular. One of the reasons is definitely that websites are getting more and more complex and reinventing the wheel each time is not acceptable if you are working on a tight schedule. But letting aside libraries and focusing on the “bare” syntax of JavaScript, it is very valuable to know what kind of options you have in terms of programming patterns when writing JavaScript.

In this article I am trying to present some of the techniques out there that I have discovered. The patterns I would like to mention are the following: The way I decided to present and compare these different patterns is by solving the same given task with every pattern. The Old-School Way Please proceed to the working example.