Business object RRS feed

  • Question

  • I have a business object with 50 properties, I want to populate a dropdownlist data (Name) do I need to create complete object and take the name value to populate data.
    or do I need to create structs to be used for these type of requirements.

    Can I use datasets for above requirements i.e instead of full object or structs.

    My data contains at least 200 records
    pl suggest the best solution for the above situation
    Wednesday, April 8, 2009 6:53 AM

All replies

  • Hello,

    I wouldn't use datasets for this. You will have problems in case it is necessary to introduce any business or formatting logic into these properties.
    There is two solutions as per me:
    1. Create base class for you business object which contains only two properties
    2. Create separate light-weight class

    First is more preferable.
    Vitaliy Liptchinsky
    Wednesday, April 8, 2009 7:32 AM
  • Thanks for reply. In this case we can have more number of classes i.e one base class (with minimum properties) and a derived class which is my actual busniss object (50 fields). but if my requirements demands same busniss object with more properties (i.e between 2 -50 used in someother class) then do I need to create one more class for that. pl suggest right approach for this type of requirement

    Wednesday, April 8, 2009 11:56 AM
  • If you build a method into your base class that automatically populates the properties of the objects from a dataset or datareader, you can then write multiple stored procedures to get the data you need.

    For example: CustomerRetrieveAll would get all customer data. CustomerRetrieveKeys would get only the key data needed for list boxes and such. Then you would only get the data you needed and only populate the portion of the business object you needed.

    The primary down-side of this approach is that any other code could assume that the full customer object is populated and attempt to work with other customer data.

    Thursday, April 9, 2009 6:08 PM
  • You can implement the "Ghost" pattern. The ideas is to use the same object for the application, but when you first load the object, it is in the "ghost" state. (only has the Id and Name properties for example, all other fields are not set). When codes try to access a property other than Id, Name; the ghost object will load it full information. You will have to be very careful with this pattern, otherwise, you will have a tightly coupled system between entities and repository
    Thursday, April 9, 2009 8:08 PM