TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Coupling in Object-Oriented Programming

4 点作者 jayferd大约 12 年前

1 comment

lmm大约 12 年前
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 <i>it doesn't have any behaviour</i>; he hasn't told us anything a Dog <i>does</i>, 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.<p>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.