1 comment

[ 5.4 ms ] story [ 9.9 ms ] thread
I think the author hasn't grasped what Fowler was talking about (and equating OO with JavaBeans is a bit unfortunate). His Dog example seems to support his point because it doesn't have any behaviour; he hasn't told us anything a Dog does, which means there's really no need for his Dog to be an object. (I was going to say it should be a struct, but actually given the use cases so far it should probably be a tagged String) Which is fine, sometimes it's the appropriate approach. In scala there's a nice distinction between "class" and "case class"; I understand some people use C#'s struct/class distinction the same way.

So yes, don't give your domain objects responsibility for serializing themselves to json. But that doesn't mean it's bad for objects to take responsibility for things that are actually part of their domain.