理论性问题,求助!

说好不能打脸
Java领域优质创作者
博客专家认证
2006-03-24 02:22:06
最近小弟在阅读《J2EE核心模式》得时候,遇到两个这样的不佳实现的描述:
1、把表现层的数据结构暴露给业务层。
2、把表现层数据结构暴露给业务领域对象。

但是小弟百思不得其解,有没有哪位大侠能给小弟解释一下,可能的话举个例子,谢谢了
...全文
224 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
ibiswang 2006-03-26
  • 打赏
  • 举报
回复
I can't use the chinese input method, I think my input files have been destroied. so I will description my option in English:

You should undstand the multi-layer programming pattern, that's mean there are many layers so that we can build a loose-coupled system.

A classic multi-layer system could be divided into three layers: presentation, business and persistence. From the presentation layer, we could gather the user input and cache them input a structed-data, often it is an ActionForm. After we have got the user input---the ActionForm, we should go into writing business code to implement the business logic, You can write all the business logic code in your action's execute method, but for building a loose-coupled system, you'd better abstract another layer---buiness layer, and you should invoked business logic method in your action's execute method, so a question will raise up: what's the parameter/object we should pass to business logic method: the ActionForm or Another object? Here should be another object, often we call it DTO, Data Transfer Object, by DTO pattern, we can divide the business layer and the presentation layer, if we adjust the presentaion layer, the business layer will be affacted very little. that's why we should not "把表现层的数据结构暴露给业务层".

In the business layer, we often write some business logic to implement our business rules or buinsess flows, in the business logic codes, we must do some curd(create, update, read and delete) opers on the target database, for good pattern to deal with the database operation, we should finish these tasks by the persistent layer, we often use the DAO pattern here. so a question will raise up, how can we pass our data in business layer--the DTO---into our DAO methods. some time , some body may want use the Domain Object as the DTO object, this may easy your coding, but if you Domain has been changed in the future, this will affact the both persistence and business layers, so the better way is you should not use the domain object as the DTO.

Ooh, my poor english!!!
说好不能打脸 2006-03-26
  • 打赏
  • 举报
回复
各位大哥,路过也帮顶一下啊,帮顶有分啊!
TinyJimmy 2006-03-26
  • 打赏
  • 举报
回复
不敢苟同。既然分了业务层和表现层,为什么还业务层还需要使用表现层的业务结构?

业务层管好你的业务就可以了,至于使用JSP还是XML输出,业务层不应关心,否则的话,业务层和具体的展现又相关了。
tomuno 2006-03-25
  • 打赏
  • 举报
回复
表现层数据结构修改时,还要修改其他层
这样修改的代码量比较大,相关的其他工作也很多,浪费时间和金钱
说好不能打脸 2006-03-25
  • 打赏
  • 举报
回复
再顶
aaa2003gf 2006-03-24
  • 打赏
  • 举报
回复
先理解MVC再来理解它吧
lydvqq 2006-03-24
  • 打赏
  • 举报
回复
UP.只用过MVC,但没有深入研究过.学习.
说好不能打脸 2006-03-24
  • 打赏
  • 举报
回复

谢谢楼上的

那么业务层和业务领域对象有什么区别呢?

现在的表现层一般采用的是HTML+服务标签(表现层助手)的方式加以实现的。
那么表现层的数据结构有具体是指什么呢??
upcmill 2006-03-24
  • 打赏
  • 举报
回复
jsp端的数据结构不要跟业务逻辑处理直接传递数据,通过PO来传递。
你可以看一下struts,他的设计思想MVC结构就是为了降低各个层之间的耦合度的。
wizardblue 2006-03-24
  • 打赏
  • 举报
回复

应该是分层,数据低藕合吧

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧