question on BO

Hi

I read a lot about BO and DTO on a couple of threads in this forum

have a question on BO based on the following threas

http://forum.java.sun.com/thread.jspa?forumID=425&threadID=575476

This thread talks about the example of zipcode and where should the validation happen, validating the number of digits can happen in DTO and validating the existence of zipcode has to be done at BO

With this understood , where should SQL for validating of zip code exists.? in the BO or some other layer?

Confused a lil here

[559 byte] By [am_newa] at [2007-10-2 12:19:12]
# 1

Not sure I undestand the question.

But as a guess you want to do a look up using the zip code value to see if it is valid. The implementation of that, at some point, requires using a database.

The SQL that interacts with the database is in the database layer. Always.

The BO interacts with the database layer.

That doesn't mean necessarily that you must have have something in the database layer that does the validation. The validation could be done as part of the insertion into the database. Or it could be done in the BO using the database layer. How you do it depends on the specifics of the application.

jschella at 2007-7-13 9:07:20 > top of Java-index,Other Topics,Patterns & OO Design...
# 2
Yes u understood my question ):When u mean database layer , is that the DAO?
am_newa at 2007-7-13 9:07:20 > top of Java-index,Other Topics,Patterns & OO Design...
# 3

> Yes u understood my question ):

>

> When u mean database layer , is that the DAO?

I meant what I said.

DAO is usually associated with a specific kind of implementation of a data layer.

Database layer is a generic term to apply to however you get to the database. You can search for POJO and hibernate as alternatives to DAO.

jschella at 2007-7-13 9:07:20 > top of Java-index,Other Topics,Patterns & OO Design...
# 4
Thanks for the replyBut am a lil confused here From what I understood about DAO after reading about it is that 'CRUD' operations has to be done in DAO if we choose to go that route.Don't the validation of zipcode in this case belong in that layer.Thanks
am_newa at 2007-7-13 9:07:20 > top of Java-index,Other Topics,Patterns & OO Design...
# 5

> Thanks for the reply

>

> But am a lil confused here

>

> From what I understood about DAO after reading about

> it is that 'CRUD' operations has to be done in DAO

> if we choose to go that route.

That is what a database layer does.

>

> Don't the validation of zipcode in this case belong

> in that layer.

>

And again it still depends on how you want to implement it.

You can choose to load the valid list into memory and cache it. The load part of that would come from the databas layer. The cache itself wouldn't. A BO would use the cache.

Or you could just call a query to see if that zip code exists. It would hit the database each time. Because that is a query it is an object in your database layer. The BO would uses it.

Or you could implement a trigger in the database that does a lookup check before a record is inserted to verify the zip code. In this case it wouldn't have anything to do with your java code.

There could be other variations on the above as well. (For instance using several of them.)

jschella at 2007-7-13 9:07:20 > top of Java-index,Other Topics,Patterns & OO Design...
# 6
thanks Jschell
am_newa at 2007-7-13 9:07:20 > top of Java-index,Other Topics,Patterns & OO Design...
# 7
Hi all,Please tell me the difference between Coarsegrained Bo and finegrained Bo?ThanksMessage was edited by: pavan kumar
cvsnta at 2007-7-13 9:07:20 > top of Java-index,Other Topics,Patterns & OO Design...