开发者

Object mapping - flattening to property instead of object reference

I am trying to refine my knowledge of N_Tier arch

Inside the BLL, and In case I am using custom business objects in BLL, like CustomerInfo {FN, LS, ...}, Consider that I have Customer table and Currency table, Customer is having a default currency, thus there is a FK Currency_ID in Customer table, at UI layer, we need to show Currency sym开发者_JAVA百科bol instead of Currency_ID. (SELECT...INNER JOIN..)

Can I put the Currency symbol as a property in CustomerInfo, instead of putting a reference of CurrencyInfo inside CustomerInfo.

I think No is the answer, but Why? What can go bad?

Should every business table (excluding validation lookups) in database maps to a business object?

I think business objects (objects which contain the data brought form DAL) should be carefully mapped to tables in database, this can increase the maintainability. But BLL can contain any objects for business operations and business validations.

Please give me some books titles, or links to master the N-tier arch and the debates about it.

Thanks


Perhaps you should read some of the many excellent books on design patterns (the Wikipedia page on the subject links to some of them). In particular, you may find the concept of a data transfer object (DTO) a good one. It is quite common practice to have a domain model that maps closely to your database, possibly using an object-relational mapping tool like (N)Hibernate, iBatis and so on, but to then have a set of converters/adapters that turn these into slightly flatter objects (like the CustomerInfo object you describe) that better fit the way our application needs to display and process the data.


If you want to use a currency symbol as a natural key to the CurrencyInfo table, why not just make it a primary key in CurrencyInfo table?

Joe Celco http://www.celko.com/ especially advocates this approach.

Celko on SQL: Natural, Artificial and Surrogate Keys Explained http://intelligent-enterprise.informationweek.com/showArticle.jhtml;jsessionid=EJ2IXIZ2R4MSLQE1GHOSKH4ATMY32JVN?articleID=201806814

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜