Software engineering blog of Clément Bouillier: 2008

Saturday, September 6, 2008

Object to object mapping : a painful task

Remark : I have to refine this post, but I publish it since there is some news on the subject : AutoMapper has been published on CodePlex (see this post on Jimmy Bogard blog).


In August 2008, I have got the same needs as Jimmy, so I have started to search on the community, I did not find any existing tool but I found these three links :

I also have a look at "the other side" (i.e. Java), and it exists a framework named Dozer. It makes implicit mapping as you explain, but for more complicated mapping, you make the mapping in XML files like (N)Hibernate does.

I would like here to detail a little bit the why I found this type of tool useful.


In the first link I give, James Gregory talked about three requirements:
  1. Refactoring friendly. No strings for property names, changing names should give compiler errors.
  2. Must simplify code.
  3. Must improve maintainability.
So, on the first requirement, configuration approach fails more or less, because in fact, you will unit test your classes which make use of the mapper (and not make unit tests for string inspection, that have no value as said by James). More over, I have got a feedback from a meeting that was I should add a fluent interface, which makes configuration much more reliable and refactoring friendly. I am more and more open to this type of API.

On the second requirement, it is the one I prefer because I am bored to write mapping code, and implicit mapping simplify it. There is a difference between mapping code and configuration complexity because in mapping code, you have to create object instances, to recurse on collections, to handle inheritance mapping (and that code is very boring), whereas with configuration, I just declare mapping between types and fields and I have implicit mapping.

On the third requirement, I think configuration is simpler than code, even if it needs to understand mapping framework.

The central point of my first implementation was a huge use of Lambda expression and it simplifies a lot the code of the mapper.
The principal features I have implemented for now are:
  • explicit mapping through XML configuration (fluent interface or at least API in mind)
  • implicit mapping based on properties name
  • recursive mapping
  • inheritance mapping (in progress)
  • conversion during mapping (through Convert class)
  • types in scope : basic types, nullables, all enumerables (including generic ones), classes with public properties
I have several elements in an Excel sheets...I will share it.
I try to use a TDD approach so unit tests exists for these features.

I am very impatient to have a look at the Jimmy implementation (AutoMapper) and perhaps to participate to this tool improvement.

Thursday, August 28, 2008

Subjects I would like to blog...

In this post, I will keep a list of some subjects on which I would like to blog (in italic drafted ones):
  • General purpose
    - Alt.Net Meeting Feedback : Object Oriented : an historical mistake or to be continued
    - Software vendors: opened on communities Vs proprietarism
    - Software quality: technical VS process ?
    - Agile and Team organization
    Classify items : hierarchical Vs relational (ex mails, docs...)
  • Technical
    - Object graph consistency, querying and (lazy) loading
    - Object Application Cache
    - SOA and legacy applications concrete integration by example: objectives, solutions, advantages/disavantages (how to integrate read/write operations)
    - Application architecture: taking best pratices together
    - Web State Management : client and server side (sessions, cache...)
  • Process & Tools
    - Test Strategy : automation of Unit + Functional Tests (both coded, not recorded)
    - Functional Test with Fitnesse and configuration management processes
    - TFS Agile Process Template
    - TFS customization
I will try to write on these subjects "shortly"...;)

Blog content

I would to open a blog for long time, but I think I have more to learn from others reading their blogs until now. Today, I am always learning a lot from others in the community, but I would like to give my 2 cents on some subjects :
  • Microsoft technologies and others (because I think there is a lot to learn from other technologies)
  • Software architecture, including every levels : business, functional, applicative, technical
  • "Software world" industrialisation, around tooling and quality
My inspiration will come from :
  • "Software world" actualities
  • Reflexion about my job and the working environment
  • Community activities (forums, informal meetings, blogs...)
I would like to warn you that I could scratch english sometimes (since it is not my mother tongue, which is the french), please be indulgent but let me know when it is unsupportable ;), I would like to improve my english also.

I often say things bluntly, it is volunteer, in order to emphasize the message I want to share, and then must not be interpreted as opinionated behavior. I have some conviction I like to talk about, but I would like to change them if I am truly convinced by any other points of view.

Now, it is time to read some not hesitate to share your thoughts, but stay correct.