tags:

views:

25

answers:

1

Hi How to design a business object?

I have a library which returns me an Object which have ten lists of other different objects. I need to store it into database all. List of objects are often like:

class Item {
   private int id;
   private String name;
   private double point;
}

But the name is often the same. Like basic title of the product or code. Containing from 3 characters up to 70characters.

Should I make conversion for every Object to: (or something similar)

   class ConvertedItem {
      private int id;
       private int code;
       private double point;
    }

And have a separated table of codes ( I guess around 60).

Or do not bother with duplicated stuff?

It's not mission critical app. What would you do in my case?

thanks in advance

A: 

If I understand your question correctly, you want to know if you should use a lookup table for the names of items because some of these items share names.

I would not bother worrying about duplicated information. Your dataset appears small; I highly doubt storing a few strings extra times would be a problem unless you are working in a very low memory environment. Unless you start talking about data in orders of magnitude of hundreds of thousands or millions, it's best to not prematurely optimize.

The case in which you might want to use a lookup table is if the names are logically shared. Meaning, if you change the name for one item then you want to change the names for all items that share that name. If this is the case it might make sense to use a lookup table.

derivation