Mapping java.util.Map to XML using JAXB

Tomas Malmsten
7 May 2012

One of the thing that can be a bit tricky when using JAXB is to map a java.util.Map to XML. In this example we have a provider object. The provider has a name and a map containing properties.

Below is the provider XML document:

Continue reading →

Clean Code – Functions – Revisited

Tomas Malmsten
18 November 2011

A couple of years back I wrote an article exploring a way to apply Robert C. Martins guidelines on how to create clean functions, taken from his book Clean Code. This created quite a stir on DZone where I also published it.

A comment from Steven Jeuris about a week ago on my blog made me want to revisit the subject again.

Continue reading →

Designing a HATEOAS REST API

Tomas Malmsten
17 November 2011

I have recently finished designing a REST protocol. There are a few things that needs careful consideration when exposing a domain through such an interface. I will gather some of the conclusions here for future reference.

The first thing to keep in mind is what a HTTP based REST protocol is and what it is not. It is not a domain, it's a protocol. It is easy to forget when modelling the domain that it's representation is only a snapshot view onto it. The REST protocol provides this snapshot view. This makes a tiered architecture fitting, with clear boundaries between presentation, I.E the REST API, domain, and then any other technical aspects such as data storage.

Continue reading →

Choosing between table mappers or DeclerativeBase when working with SQLAlchemy

Tomas Malmsten
2 November 2011

I have recently been looking how to create a clean Domain Driven Design architecture using SQLAlchemy and specifically how to map domain classes to tables. This post will discuss the two techniques available and why to choose one over the other.

Lets start with looking at the two strategies available. SQLAlchemy offers a [Data Mapper(http://martinfowler.com/eaaCatalog/dataMapper) out of the box. It is also possible to use an Active Record approach by using the Declarative Base ORM extension.

Continue reading →

Valuable returns for writing Clean Code

Tomas Malmsten
2 November 2011

In the project I am currently working on I have a lot of code to write. It's a green field project delivering a new platform and I have no frameworks to borrow from or extend. So I have to write the code for each single feature by hand.

I am not complaining. I like writing code. But it takes time, especially since it's only me on the project at the moment.

Continue reading →