tags:

views:

42

answers:

1

I have some code which translates one domain object to a second domain object. One of the field values in the second object is translated via a long function containing a lot of “If then else” and return statements (100 lines of code). You can say, that several of the fields from the first object is used to determined the value of 1 field in the second domain object.

And now for the question, is there a pattern to make this more readable? … and maybe extract these rules for the stake holders?

A: 

Sounds like business logic to me. Check out a screencast showing modeling of decision tables made by my employer. That's a way which is appealing to business stake holders, as they are also able to provide such rules on their own, e.g. make modifications and provide new rules on their own.

I can't give a code-based design pattern for that kind of problem though other than trying to encapsulate it in a clean Business Object or even in a Service.

mhaller