Exception Handling in Object Oriented Design

I am developing a huge web based project using Object Oriented design and java,srvlets ,jsp etc ,I am using 3-tier archtecture.I dont understand,how i should handle exceptions in my project.ie.If there is some exception in the base modules how should it be handled.What kind of excpetion Structure should i use,How many exception classes should be made etc,
Can someone help me in this regard

A couple things I have found to be good practices for exception handling in an n-tier architecture:
1. Don't expose all the internal exceptions of a tier to the client of the tier. Create a more useful, descriptive set of exceptions (or use the appropriate predefined exceptions) to throw up to the client.
For example, on one project, we are doing database access among other things in the "service" tier, which is accessed by the web tier. We catch the SQLExceptions, PersistenceExceptions (a custom exception), and others, and throw a more useful exception that the client will know how to handle such as a NoMeasurementResultsException if the client asks for measurement results when we have none.
2. Chain your exceptions and/or log the root cause in the tier that re-throws a different exception. There is nothing more aggravating than not knowing why, when you are debugging a problem, you are getting a NoMeasurementResultsException when you know that there ARE results in the database.
Hope these ideas help in your design.
Cheers,
Colin

Similar Messages

  • Good book on Object Oriented Design?

    Can you recommend a good book on Object Oriented Design with lots of practical examples? I already have:
    http://www.amazon.com/Design-Patterns-Object-Oriented-Addison-Wesley-Professional/dp/0201633612/ref=sr_1_1?ie=UTF8&qid=1238324375&sr=8-1
    But currently I need a book with a more basic approach.

    corlettk wrote:
    I like Thinking In Java... Also: google for "yawmark's list"TIJ is useless, especially for teaching OO design. It teaches (or tries to) Java as a procedural language.

  • Object Oriented Design in Java

    I am an RPGIV programmer trying to switch to Java. I have some experience with Java syntax and basic fundamentals. My question pertains to OOP specifically. I am trying to write a version of the old C-robots program in java. It was an AI simulation project written in C years ago where you could modify the actual AI code and then implement it to test results with 3 other robots with different AI. My question is this: When trying to break down the methods for an interface client to control the robot objects, how do you know what messages that particular client should take care of. In a GUI version I imagine that all the interface client would need to know is basically getPosition() and getDamage() for the display. Then the robot objects would handle all of the other methods including moving(), scanning() and shooting() just to keep it simple. (many more methods are needed, I know). i guess in a nutshell i am trying to determine good program design when it comes to object responsibility. how much responsibility should the interface have as opposed to the other. thank you

    Hi! Welcome to Java. You have a rather broad-based question which primarily deals with good o-o design.
    I'd recommend reading the chapters relating to o-o design from Bruce Eckel's "Thinking In Java". The electronic edition of the book is available for free download at http://www.bruceeckel.com.
    Now, regarding the interface client, you need to determine what other entities it will interact with and from that determine what methods it must have in order to permit those interactions. That's a rather short way of putting it, I know. However, hopefully that's enough to get you going.
    Hope this helps! Feel free to ask if something's not too clear.
    Cheers!

  • Handling shared objects in designer 10g

    I have 2 application dump that i should import in designer 10g. I had imported the first dump with the help of import option present in Restore menu option these contains 11 applications with its own sharing . Then i restored the second dump in the same manner.The second dump has 16 applicaitons .In the first dump i have two applications let us call it A and B .These A and B 's objects are referenced by applications C AND D in second dump and by some of the applications in the first dump itself .Now the issue is these A and B exists in both the dump, while restoring ,i was compelled to change the name of the application so that i can avoid duplication .In this way iam able to import. Hence , i would like to know if there is any methodology to avoid these duplication.

    yes, and no ....
    If you have versioning enabled, then the import will allow you to bring in the second copy of A and B as "new versions of existing elements". But that would imply that you have defined and implemented your version control processes and decided how were using version control / SCM in this repository. Not a simple thing, so .....
    If you have a non-versioned repository, then sorry NO not during import.
    This is because of the way the export was created. When you export you include a complete consistent set of applications that you want to import somewhere. Designer makes sure that you have ALL the elements you need. Thus you have A and B in both those exports.
    The real answer is to export A, B, C, D, and their friends as a single export file -- if what you really want to do is import them all and preserve the sharing.
    One avenue is to check with the odtug.com group / mailing lists. Someone over there may have written current scripts to do a "replace" of all pointers to A' elements with pointers to A elements (((this was part of Designer 6.0 Echo, but not 6i/9i/10g - sorry)))

  • Question about Object Oriented Design in Oracle

    Hi everyone,
    Right now I'm updating my oracle skills, years ago without programming (last time with Oracle 7.3 :O)
    Well, if I have to design a new system with this features:
    1.- Using Oracle as DB
    2.- Web enable
    3.- OO Design
    My questions:
    1.- What is the best practice to make database design? E-R + Object Types? I mean is better making the design on Oracle directly or in Java-UML environment?
    2.- I was thinking in programming with Forms, but it works well with OO design?
    3.- If I want to program some web services based, Could I do it with PL/SQL and Jdeveloper?
    please if you know about articles and whitepapers about OO design approach with Oracle let me know!
    Thanks.

    I have been involved in some of these projects that have used Java, C#, VB, C++ etc. as front-end languagaes. I have been able to implement these projects successfully using the following approach:
    1. create a relational model of the database - third-normal form (assuming it is an OLTP application)
    2. Write PL/SQL code (packages and procedures mainly)
    3. Interact with the front-end layer by sending and receiving ref curosors and/or PL/SQL tables
    If you want to use Forms (I am assuming Oracle Forms) then there may not be much need for an OO design. Embeeding SQL in the forms will do most of what you want.
    Shakti
    http://www.impact-sol.com
    Developers of Guggi Oracle - Tool for DBAs and Developers

  • Theoretical object oriented design question

    Hi,
    I am just getting into the design of some software that will take either one or two numbers and perform identical operations on them. It will then create a label that will be different depending on whether 1 or 2 serial numbers are used.
    In the example it looks like I could make a vehicle class that would contain the serial number, and child classes for car, truck and boat that would define how the sticker was laid out.
    The trouble I am having is that the control for serial number 1 and serial number 2 need to accept any of the three numbers for car truck and boat.
    So I am not sure how to build classes to cover this, and what design pattern would be best.
    So I am looking for ideas.
    I have no real code yet to post, and a lot of the attributes are confidential, which is why I made the simple diagram.

    Search this site for...
    Factory Pattern
    It basiclly uses a case sctructure to to select a Class constant of the proper type.
    Have fun!
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Using UML while designing Object oriented design in ABAP

    Hi,
    Is it a general practice in projects to use UML diagrams when you do OO design for a report in ABAP ? Or do people start writing th OO code directly ?
    Reards,
    Rajesh

    Hi Rajesh,
    In my particular case, I use to start writing the code directly after I read and check the documentation. Right now i'm starting to looking around in order to get more experience in OO programming.
    I think that UML is the best option right now, also SAP recommends it. They worked with Rational Software in order to provide an external modeling tool to supports SAP's class.
    Check this link in order to get more information.
    <a href="http://www.sapinsideronline.com/archive/volume_03_(2002)/issue_03_(july-september)/v3i3a11.cfm?session=&promo=iz1321">http://www.sapinsideronline.com/archive/volume_03_(2002)/issue_03_(july-september)/v3i3a11.cfm?session=&promo=iz1321</a>
    Regards,
    Eric

  • Backing Beans Object Oriented Design

    Hello,
    Are there any best practices for using Backing Beans?
    How to make managed beans thread-safe for concurrent requests,
    without compromising on efficiency/speed?
    2. How to enforce the J2EE security with backing-beans?
    3. How to decide the scope of these beans to ensure minimal data-storage
    in session?
    4. How to decide the granularity at which a managed-bean should be used
    for example :
    4.1 One bean-per-component
    4.2 One bean-per-form
    4.3 One bean-per-page
    Also i would like to know how to design managed beans from reusability perspective.
    Regards,
    Smita

    It quite hard to give a brief answer on all your questions.
    I think that you should take into account bean's scope when think about thread safety.
    Request scope bean is single threaded while for session scope you should provide locking mechanism because this bean can be accessed from different threads but only in case when one user simultaneously submit request from multiply browser windows.
    As for security you can use standard security API from within bean through javax.faces.context.ExternalContext
    It is convenient to use one backing bean for some or all components in web form.
    Do not mix form component and business data in one bean. Thus it is good design to have one set of beans for presentation logic and another one for business logic.

  • Object oriented design problem concerning abstract classes and interfaces

    I have an abstract class (class A) that takes care of database connections. It cannot be made into an interface as other classes extend it and all these other classes require the functionality in the methods it has (i.e. I cannot make all the methods abstract and then make this class an interface).
    I have a class that contains data (Customer class) that I will create from the data I extract from the database. This class will also be created by the User and submitted to the database portion of the program. The Customer class has functionality in its methods which is required by the rest of the program (i.e. I cannot make all the methods abstract and then make this class an interface).
    I have a factory class (CustomerFactory) that extends the Customer class. This has been created to restrict access to the creation and manipulation of Customers.
    I have a class (DatabaseQuery) that extends class A. But now that I have retrieved all of the information that comprises a Customer from the database, I cannot construct a Customer without making reference to UserFactory. But UserFactory is a class that I don't want the database portion of the program to know about.
    What I would like to do is have my DatabaseQuery class extend both Customer class and A class. But they are both classes and Java won't allow that.
    I can't make either of the two classes that I want to make parents of DatabaseQuery into interfaces... so what can I do other than just keep a reference to UserFactory in my DatabaseQuery class?
    Thanks,
    Tim

    >
    What I would like to do is have my DatabaseQuery class
    extend both Customer class and A class. But they are
    both classes and Java won't allow that.
    I can't make either of the two classes that I want to
    make parents of DatabaseQuery into interfaces... so
    what can I do other than just keep a reference to
    UserFactory in my DatabaseQuery class?Just a guess...
    The description sounds a little vague but it sounds like the correct solution would be to refactor everything. The first clue is when I see "database connection" as an "abstract class". The only hierarchy that a database connection might exist in is in a connection pool and even that is probably shaky. It should never be part of data records, which is what your description sounds like.
    That probably isn't what you want to hear.
    The other solution, which is why refactoring is better (and which also makes it apparent why the original design is wrong) is to create an entire other hierarchy that mirrors your current data hierarchy and wraps it. So you now have "Customer", you will now have "Customer" and "DBCustomer". And all the code that currently uses "Customer" will have to start using DBCustomer. Actually it is easier than that since you can simply make the new class be "Customer" and rename the old class to "DBCustomer". Naturally that means the new class will have to have all of the functionality of the old class. Fortunately you can use the old class to do that. (But I would guess that isn't going to be easy.)

  • Object oriented design -book

    Hi
    I'm looking for a good book about oo design. I'm interested in a book showing how to divide real-life probleminto set of classes and methods. Explaining few oo design's methods and so on... I would be really greatful if could recommend me such a kind of book?

    LOL, thank you scarlet for cheering up my ever so
    painful monday morning.Read again. Rene = Frenchman. Scarlet = Limey. I'm
    not him.oops, like i said, "i don't like mondays"
    humming "...I don't like jamaica, i love it ya...".
    I have "Teach yourself the Washing Machine in 21
    Days", but I think there's a misprint somewhere. My
    clothes don't look like 600�C were a good idea... but
    OTOH, maybe I'm doing something wrong. I'm still at
    Day 3 (how to undress before washing the clothes).That misprint sucks.
    But i'm very interested in how you did wash your clothes on 600�C without finishing day 3 first.
    A small hint: I have found the perfect solution so I didn't had to buy that book (I saw it was actually one of the expensive ones in the serie), I got engaged, thinking that would be cheaper.
    I couldn't be more off on that one.

  • Question about Object-Orientated design for GUI'S

    Hi everyone,
    I am designing a simple GUI, which basically enables a user to input and retreive data.
    So I have a prototype GUI lets call it "myFrame". It extends JFrame, and I place my components onto myFrame, JButtons, JTextfields etc. I have the GUI set up the way I want it, so I move onto implementing the actionListeners.
    The problem is that one of the components I have placed on myFrame has its own mouseListener. Its a type of Icon (i created in a seperate class)which extends JComponent, and I thought it would be sensible to give it control of its own mouseListener, so it cuts down on the code within the myFrame class.
    But I now realise that I can't alter the other components on myFrame from within the mouseListener in the icon class. I know the icon class doesn't have access to any of myFrames methods or instance fields, so how do I correctly implement this. Surely the answer isn't to bung all the code together into one class?
    visually what I have so far looks like this
    SERVER <---Requests---> myFrame --------> IconList ---------> Icon
    the IconList class looks up a server to update its array of Icons[]. But when one individual Icon is clicked on myFrame, i want its mouseListener to load some of its values onto myFrame's GUI components.
    I hope I'm making myself clear, im sorry if this seems like a muddled incoherent question, but any advice would be great. I only need to be shown the correct way to design, and then i carry on coding happily. If this kind of design is way off, please let me know!!
    Thanks

    You can absolutely do work on the frame from the mouse listener--It just needs an instance. i.e.
    public class MyMouseListener implements MouseListener {
      private MyFrame frame;
      public MyMouseListener(MyFrame frame) {
        this.frame = frame;
    }Does that make sense?
    That said, what you'll see more often is a Model-View-Control approach, wherein the Control (the mouse listener in your case) effects the Model and the Model notifies the View to update its display, rather than the Control updating the view directly. That's the extreme overview version, lots of good hits on google if you're interested beyond that

  • Proper object oriented design for factory class

    I have a factory class (UserFactory) it is capable of creating two types of classes (Customer and Employee) that extend User. User is an abstract class.
    At present any class could create a Customer of an Employee.
    How do I restrict access to the constructors of Customer and Employee only to UserFactory?
    I don't want to make both of these classes interfaces (in which case I could just have UserFactory implement both of them).
    Here is an example of how they are set up at present:
    public abstract class User {
    public class Customer extends User{
    public Customer{
    public class Employee extends User {
    public Employee {
    public class UserFactory ???? {
    private static UserFactory c_userFactory = null;
    private UserFactory (){
    public UserFactory getInstance(){
    //private clone method too
    public Customer createCustomer(){
    public Employee createEmployee(){
    Oh and I don't want to create two separate factory classes for Employee and Customer. In C++ there is a concept of friend classes that would have worked nicely in this case.
    Thanks for any and all suggestions,
    Tim

    So correct me if I'm wrong but your suggestion would be something along the lines of:
    public abstract class User {
    public class Customer extends User{
    protected Customer(){
    public class Employee extends User {
    protected Employee (){
    public class UserFactory ???? {
    private static UserFactory c_userFactory = null;
    private UserFactory (){
    public UserFactory getInstance(){
    //private clone method too
    public Customer createCustomer(){
    public Employee createEmployee(){
    public class AccessForCustomer extends Customer {
    public class AccessForEmployee extends Employee {
    Is the above about what you were talking about? I haven't used inner classes before, so I'm a bit curious. Does this mean no class other than UserFactory or derivatives thereof can access the two classes AccessForCustomer and AccessForEmployee?
    Thanks,
    Tim

  • Object oriented programming on PXI-System

    Greetings,
    i've developed some object-oriented LV classes, wich i've succesfully tested on my desktop pc. The next step would have been to test them on a PXI-controller. However, the LV 8.20 methods of object oriented programming seam to be incompatible to PXI-systems.
    All i'm getting is an broken arrow with an error message like that
    HardwareIOAnalog.lv.class:setTimingNP.vi
    Frontpanel-Anschluss 'HardwareIOAnalog in': Der Typ wird für das aktuelle Ziel nicht unterstützt (means: Type not supported by current target)
    Does that mean that object-oriented design is not supported in general by PXI, or is it depending on the type of the PXI-System. Is there an easy way around, or do i have to re-program all my classes to conventional (Sub)VIs?
    Help appriciated! ;-)
    Regards,
    Bennet Gedan
    Student (Electrical Engineering/Mechatronics)
    Darmstadt University of Technology
    Bennet Gedan
    Student (Electrical Engineering / Mechatronics)
    Darmstadt University of Technology

    Okay, thanks. Meanwhile I reprogramed the whole thing and set OOP aside (at least on the PXI-Target). It's a pity to loose some advantages of OOP, but it brougth me some interesting new programing techniques i could transfer to non OOP stuff.
    Regards,
    Bennet Gedan
    Student (Electrical Engineering / Mechatronics)
    Darmstadt University of Technology

  • What are the basic pillars of Object Oriented Programming?

    there are 3 pillars of OOP which are Encapsulation, inheritance, polymorphism, but i heard lot's of people even companies software engineers use abstraction is a pillar, i haven't find it from MSDN why abstraction is not a pillar ?

    Whereas encapsulation, inheritence and polymorphism are specific implementation details of OOP (i.e. the key ideas that make programming
    object-oriented), abstraction is a high-level way of looking at your overall application design.
    For example, in a simple database application you would not want to write your code so that your user-interface, business logic, and database code was all hard-coded and "tied" to each other.
    Ideally you would think about your design and try to plan your application so that your user-interface code is independent of your business logic code (which can be "plugged-in" and/or changed as necessary), which is again independent of your database
    code such that you could even switch to a different database and only need to change that one part of your code-base.
    As an example, you might not pass a class representing some business logic directly into your user-interface code. Rather, you may want to create an interface representing a generic way of representing your logic that could be re-used by lots of business
    classes. It is then this interface that could be used by your UI code or database code to validate data, rather than specific classes. Then you could create more classes in future that just have to implement the same interfaces, knowing that the rest of your
    code would not need to change. This is just one aspect of "abstraction".
    If you do a search for "application design patterns" or "object-oriented design patterns" you will find plenty of articles and books on how to go about doing this.

  • How do YOU name classes? (object oriented programming)

    I am in the process of learning advanced object oriented design, and I am trying to use it in my personal programming project. I'm having a hard time implementing all of the classes I want for it because I can't think of what to call them.
    So, my question is, in object oriented design, how do you name the implementations and abstractions that you make?
    In other words, "implementations" can be thought of as "classes", and "abstractions" as "interfaces" in Java or "pure abstract classes" in C++. How do you name the classes and interfaces you make?
    For example, do you use prefixes or suffixes on your names, such as "I" for "interface" or "Impl" for "implementation"? Do you add "-able" to the end of the name of an abstraction, such as "Decoratable"? Can you always think of simple logical names for all of your classes, and it just has never been a problem for you?
    As an example of how the number of classes quickly grows, the Decorator Pattern will use at least five classes. I have no idea what I would name those in a programming project.

    drcouzelis wrote:
    Trent wrote:Theoretically speaking, you'll have multiple implementations of the Window interface, which will have their own unique names suggested by their respective purposes.  If not, then Window and its implementation should probably be merged into a single class.
    Thank you for bringing that up.
    How about this: The name of the implementation class will be HOW its implemented followed by the name of the interface.
    A "Window" interface would have implementations such as "AllegroWindow", "GTKWindow", or "HaikuWindow".
    In a video game, a "Character" interface would have implementations such as "GeneralCharacter", "ControllableCharacter", "PlayableCharacter", or "EnemyCharacter".
    Does that sound like a good idea?
    Indeed, classes are more specific than interfaces, subclasses are more specific as their superclasses... This should be reflected in their names, the name of a class that implements an interface should somehow make clear exactly what it is (e.g. what kind window). If you have a kind of window (for instance) that is really _just_ a window, nothing else, than the interface should become this class and the implementing classes should become subclasses.

Maybe you are looking for

  • Using a Variable Prompt - In an analysis using Top N filter (URGENT)

    Hi Experts I have created a variable prompt that is setup in the following way : Prompt Name : Number_of_rows User Input : Radio Buttons Radio Button Values : *1/ 2* (Custom Values) Variable Data Type : Number Default Selection : *1* (Specific Custom

  • Is it possible to develop the control charts in WAD.

    Hi Gurus and Experts We need your suggestions to go futhure with our requirement. Right now KPI's are currently displayed in graphical form with the ability to drill down into WO's( Work orders) from the graph page. our new requirement is to get exac

  • How to give link between 2 customized layout in f110 transactions.

    Hello Abapers, I am developing customized layout for f110 transaction.I have developed layour for cheques as zcheques and for payment advice,i have developed layout as zpayadvice.When i am running f110 transaction..it is giving output of cheques only

  • Start and manage applications from creative cloud

    Hi, why not be able to start Adobe CC applications from the Creative Cloud itself? Why not manage them from it, to uninstall, additionally to update or install? I've needed this during the switch to CC 2014. Why not re-install option too? In the proc

  • Seminar Glassfish/Opent ESB Java CAPS in Brussel 4-5 Oct 2010

    Hello All We are happy to inform you that an Glassfish/Open ESB / Java CAPS Seminar will take place in Brussels (Belgium) Monday 4th and Tuesday 5th of October 2010. A web site dedicated to the seminar will be accessible soon then we will provide you