aggregation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sridharvenkataramanan
    New Member
    • May 2010
    • 7

    aggregation

    i have a class where i am storing the error header information and another class to store the details about the errors like the following
    header
    ---------
    id, name

    details
    ---------
    field id
    changed value
    original value

    now i want to create an instance to header class through which i need to input values to details and well the single header class can have multiple details

    say
    1,"x","101","ab ","mm"
    1,"x","102","mx ","zz"

    something like the above.

    i have seen couple of examples like aggregation of header with details
    but they requires two instances.

    Could you please guide me to proceed in oops way....
  • Christian Binder
    Recognized Expert New Member
    • Jan 2008
    • 218

    #2
    I hope, I've understood your problem correctly:

    If you get
    1,"x","101","ab ","mm"
    1,"x","102","mx ","zz"
    , you want to create one instance of Header-class (1, "x") and two instances of Details ("101","ab","mm " and "102","mx","zz" )

    Is that right?

    You could use a management-class, which holds all Headers and provides a method e.g. GetHeaderInstan ce(id, name).
    This method checks, if a instance of Header exists with given id and name (therefore it has a List with all instances of Header). If not, it creates one and stores it in the Header-List.

    Comment

    • sridharvenkataramanan
      New Member
      • May 2010
      • 7

      #3
      Thanks for the immediate response.

      If you could throw some more lights or a simple example for the same would be very much helpful,.

      :) thanks

      Comment

      • sridharvenkataramanan
        New Member
        • May 2010
        • 7

        #4
        I hope i have solved this in the following way. is it right?

        i have used class details as aggregation with class header and added multiple values to the dictionary object pointing to the details
        like the followings.
        Dictionary<stri ng, Details> objDetails

        Comment

        • Christian Binder
          Recognized Expert New Member
          • Jan 2008
          • 218

          #5
          Yes, this should be okay. So you can add multiple Details to a Header.

          Comment

          Working...