Hard code the values of DB.

Before I start work on a DB- I thought to execute code with JSP- Formbean- Action Servlet- Business Class- DAO flow. Is it possible to hardcode values and retrieve it from DAO? Pardon me if this sounds dumb question. Thanks,
[238 byte] By [PaviEluri20a] at [2007-11-27 9:10:24]
# 1
I am not sure how to hardcode the values. My guess is it should be coded somewhere in formbean. Correct me if I am wrong. Waiting for your reply tigers..Thanks,
PaviEluri20a at 2007-7-12 21:51:53 > top of Java-index,Other Topics,Patterns & OO Design...
# 2

> Before I start work on a DB- I thought to execute

> code with JSP- Formbean- Action Servlet- Business

> Class- DAO flow. Is it possible to hardcode values

> and retrieve it from DAO? Pardon me if this sounds

> dumb question.

> Thanks,

What for? Testing purposes, I presume. Yes, it's possible - and common - to have your DAO return hard-coded values your client code will expect, in order to focus on another layer until you're ready to actually get the DAO working

One approach would be to gradually push the hard-coded values down layer by layer, first having your JSP hard-coded with them, then get the JSP to obtain values from a form bean, which has them hard-coded, and so on, until you've got end-to-end real data flowing about. This way of working avoids the tedious, even daunting "how will all this fit together?" lines of thought that most people mistakenly go down early in their coding career

georgemca at 2007-7-12 21:51:53 > top of Java-index,Other Topics,Patterns & OO Design...
# 3
Mock objects (the implementation that returns fixed values for test) can also be used in an ongoing basis for unit testing each layer.
jschella at 2007-7-12 21:51:53 > top of Java-index,Other Topics,Patterns & OO Design...
# 4

> Mock objects (the implementation that returns fixed

> values for test) can also be used in an ongoing basis

> for unit testing each layer.

Of which, EasyMock seems to be the most straight-forward example I've seen. Others will have different opinions, of course. Try 'em all

georgemca at 2007-7-12 21:51:53 > top of Java-index,Other Topics,Patterns & OO Design...
# 5
You can of course just roll your own.
jschella at 2007-7-12 21:51:53 > top of Java-index,Other Topics,Patterns & OO Design...