• Post Reply Bookmark Topic Watch Topic
  • New Topic

what is the best way to separate layers in data structure  RSS feed

 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all
I have data structure that is part of the application lts call it MY_DATA
now my application can be used as part of web tier and also as stand alon not part of the web tier
now my costom MY_DATA is using : javax.servlet.ServletRequest for web use .
but my problem beggins when I exporting the application jar for use NOT in web container env , then
it gives me error of cource that its looking for this jar .
i like to find away probblly in design that MY_DATA will be first of all for use in not WEB container env
and if I like to export it to WEB env I could add him or extend it with the web methods that using javax.servlet.ServletRequest
but always I will refer to my data structure in my code as MY_DATA

thanks
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your goal is A Good Thing. See if this thread answers the right questions.
[ October 29, 2006: Message edited by: Stan James ]
 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wow , i was reading the post again and again but i dont get it how can it help me here .
sorry but i still dont get it maybe i will put some code to explain my problem
say i have this class :

now this application uses this MY_DATA structure BUT this application can be used
in web layer then it needs the request import ,and else this application can be exported as
stand alone application then i dont want any imports that are web related like : javax.servlet.ServletRequest , i know i need to build / design my classes in different way
so they will be aware of this but i have no idea what pattern or way to adapt .

i have difficulty to understand .
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The goal is to remove the import javax.servlet from your data so let's start there and see what we have to do to make it work again. In short, some other class that knows about servlet and your data object will have to move the data around. Maybe a servlet would do this:

Now MyData doesn't have to know about the request object any more. Your other standalong application could create and populate MyData the same way, just from some source other than the request.

This is the typical order of layering dependencies for reuse. It goes something like:

Since MyData does NOT depend on the worker class, servlet, swing, etc we can reuse MyData with any kind of new application.

Is that working for you?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!