Wednesday, October 31, 2007

Architectural Quality Attributes

Two quality attributes to which an application architecture should adhere:

I) It is important that an application architecture can accommodate new requirements without big changes in the implementation. Changes should be as local as possible, keeping the impact small. (not everything can be tested in an automated manner).

This means that the delta in requirements should be linear towards the delta in implementation changes. I call this an architectural quality attribute. (see also book Software Architecture in Practice)

II) An architecture should have one way of doing things and allow for exceptions.

For example an architecture that has two different ways of sharing information, for example through a remote service call or storing information in a database, does not adhere to this quality attribute.

Wednesday, October 17, 2007

Using EasyMock2

The recording and playback phase of EasyMock has always drove me away from it, but I got sick of implementing mocks myself, so I gave it a try.

The simplicity is appealing. The record and playback is not as annoying as I thought it would be. However what is a bit frustrating is that i'm not interested so much in the collaboration between the class-to-test and the mock, but just in the-test-to-class. If i'm not mistaken; I want to use the mock just as a stub.

Example: i've a component that uses a dao. I want to mock the dao. For example return a fixed collection of items for a particular method. This is easily feasible with EasyMock.

Other example: i've a component that uses a HttpServletResponse. My component sets the header, content-type and some other stuff. I'm only interested what is written to the response. So I do not want to implement the setContentType and other methods. However afaik you can't tell EasyMock just to ignore calls for all methods - except for the ones you have specified during recording.