Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Design Pattern & UML  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 请问数据组装与模板替换有没有相关的pattern?
tier3





发贴: 228
积分: 120
于 2004-08-20 21:14 user profilesend a private message to usersend email to tier3search all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我们现在有一个问题,是关于数据组装和模板替换方面的,
请教各位高人有没有相关的通用解决方案?

具体的需求是这样的:

一边是数据集:
DNAME,LOC,JOB,ENAME,SAL
ACCOUNTING,NEW YORK,CLERK,MILLER,1300
ACCOUNTING,NEW YORK,MANAGER,CLARK,2450
ACCOUNTING,NEW YORK,PRESIDENT,KING,5000
RESEARCH,DALLAS,ANALYST,FORD,3000
RESEARCH,DALLAS,ANALYST,SCOTT,3000
RESEARCH,DALLAS,CLERK,ADAMS,1100
RESEARCH,DALLAS,CLERK,SMITH,800
RESEARCH,DALLAS,MANAGER,JONES,2975
SALES,CHICAGO,CLERK,JAMES,950
SALES,CHICAGO,MANAGER,BLAKE,2850
SALES,CHICAGO,SALESMAN,ALLEN,1600
SALES,CHICAGO,SALESMAN,MARTIN,1250
SALES,CHICAGO,SALESMAN,TURNER,1500
SALES,CHICAGO,SALESMAN,WARD,1250

另一边是模板:

##DNAME## ##LOC##
##JOB##
##ENAME## ##SAL##
Sum for ##JOB## ##SAL.sum##
Sum for ##DNAME## ##SAL.sum##
GRAND TOTAL ##SAL.sum##

要求循环所有的数据集,把他们按照模板排列好,替换其中所有动态值,
所有summary值,最后输出结果。

请问大家遇到过类似的问题吗?
有没有相关的通用的解决方案?多谢了!



作者 Re:请问数据组装与模板替换有没有相关的pattern? [Re:tier3]
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2004-08-20 21:46 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
This is more like sending data to the view in spring web.

I know folks using velocity to do this(just stripping html part).



"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler, Refactoring - Improving the Design of Existing Code
作者 Re:请问数据组装与模板替换有没有相关的pattern? [Re:tier3]
tier3





发贴: 228
积分: 120
于 2004-08-23 12:11 user profilesend a private message to usersend email to tier3search all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
I know of Velcity, but it is related to from Business layer to Presentation layer, my requirement is within business layer.
most of the tools currently in the market all are related to presentation layer, that is not what I want. Smile



作者 Re:请问数据组装与模板替换有没有相关的pattern? [Re:tier3]
zyzhang

Explorer



发贴: 155
积分: 30
于 2004-08-23 17:51 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
I think the concept or spirit using by Velcity, JSP page or what ever template-like product are essentially the same. Generally speaking, you donot need to do this kind of programming by yourself.

If you do need to create your own solution, i think you have to find a way to interpret your template defined and integrate with the result set(metat data mapping) from jdbc.

The Interpreter design pattern of GoF is a good reference to deal with the language template related implementation(If complicated enough, the parser generator with Interpreter pattern can work together).

Regarding the integration of data base, the book "Patterns of Enterprise Architecture" by Martin Fowler is a good referenced.



作者 Re:请问数据组装与模板替换有没有相关的pattern? [Re:tier3]
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2004-08-23 23:08 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
I mean we use a view tool to do business logic, Tounge. After all, a tool is just a tool, as long as it serves the purpose. Sometimes, we use 钳子 as 锤子.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler, Refactoring - Improving the Design of Existing Code
作者 Re:请问数据组装与模板替换有没有相关的pattern? [Re:tier3]
主管





发贴: 448
积分: 100
于 2004-11-05 17:20 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
小心过度设计哦

最简单的方案,1搞到数据库里,用数据库搞定
2用execel搞定

你要的是解决问题,不是时髦的pattern
如果有其他要求那是另回事,你没讲,没有问题约束怎么出方案




flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923