Hi all, I have been programming badly for 7 years now from C to ASP to Visual Basic and now in Java. I have just gotten into object orientation along with design patterns. I also hava absolutely no one at my company that I can ask OOP design questions to because no one puts even the least amount of energy toward good design and/or proper relationships. So I am very happy for this forum. I am very new I don't want to sound like an idiot but I need help. Here is what I am trying to do and this is the best I can articulate it for now:
I am writing a communications layer with servlets to talk to third party software.
Xml is always used as our means of communicating.
Every single servlet/class will have to build an xml doc, call this third party software and then parse the result and either fill up a hash map and ship that off to a client or write to a database or just plain log something.
Then all have to send an email if an error/exception happens
There are multiple servlets I have to call
There are multiple servlets that can be called and some are the same
The specific concrete servlets know in themselves 2 main things; what servlet address to use and what the xml it has to build looks like.
If you need more I can give it to you but I am new to this and trying to learn how to put all the relationships together.
I have an abstract BaseServlet that will implement the call to the third party, actualy it has a private member variable to a communicator class that actually implements that. So the function in the base would simply be communicator.call(servletAddress, xml); It also would have a protected memeber xmlBuilder for all children to use.
then I have an abstract HashMapWriterServlet that extends Base Servlet that will write out the hash map to the ones that need to and obviously those concrete classes will extend this one.
Then the other concrete servlets will extend BaseServlet directly
I have a couple of problems. One being the way this is used. The user would be calling the concrete servlets like
(which extends HashMapWriterServlet) and then I would get the specific servlet address from the web.xml and call xmlBuilder.buildConcreteServlet1Xml(); and then call super.call(servletAddress, xml)
Now just from the things I've seen super is usually called first and it seems in some cases where there is 3 levels of extensions I would call super.call() and then again in the next parent, do something and then again in the next parent which just doesn't seem right. Also for exception handling I want to handle it all in one place. I have no idea how to do this. Should I use like an exceptionHandler class that is a protected memeber in the base class. Should the base class have a helper class that actually makes the calls. Should I just make the call class in the parent call(whereDidIComeFrom) and then do a bunch of if's in the base, then I can just surrond the whole thing with a try/catch and handle it in there.
I hope this makes some kind of sense and that I gave you enough info.
Thank You in advance
Brian
I am writing a communications layer with servlets to talk to third party software.
Xml is always used as our means of communicating.
Every single servlet/class will have to build an xml doc, call this third party software and then parse the result and either fill up a hash map and ship that off to a client or write to a database or just plain log something.
Then all have to send an email if an error/exception happens
There are multiple servlets I have to call
There are multiple servlets that can be called and some are the same
The specific concrete servlets know in themselves 2 main things; what servlet address to use and what the xml it has to build looks like.
If you need more I can give it to you but I am new to this and trying to learn how to put all the relationships together.
I have an abstract BaseServlet that will implement the call to the third party, actualy it has a private member variable to a communicator class that actually implements that. So the function in the base would simply be communicator.call(servletAddress, xml); It also would have a protected memeber xmlBuilder for all children to use.
then I have an abstract HashMapWriterServlet that extends Base Servlet that will write out the hash map to the ones that need to and obviously those concrete classes will extend this one.
Then the other concrete servlets will extend BaseServlet directly
I have a couple of problems. One being the way this is used. The user would be calling the concrete servlets like
(which extends HashMapWriterServlet) and then I would get the specific servlet address from the web.xml and call xmlBuilder.buildConcreteServlet1Xml(); and then call super.call(servletAddress, xml)
Now just from the things I've seen super is usually called first and it seems in some cases where there is 3 levels of extensions I would call super.call() and then again in the next parent, do something and then again in the next parent which just doesn't seem right. Also for exception handling I want to handle it all in one place. I have no idea how to do this. Should I use like an exceptionHandler class that is a protected memeber in the base class. Should the base class have a helper class that actually makes the calls. Should I just make the call class in the parent call(whereDidIComeFrom) and then do a bunch of if's in the base, then I can just surrond the whole thing with a try/catch and handle it in there.
I hope this makes some kind of sense and that I gave you enough info.
Thank You in advance
Brian