comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Design of cross referring types/classes and proper usage of containers
Date: Mon, 3 Aug 2015 18:22:18 +0200
Date: 2015-08-03T18:22:18+02:00	[thread overview]
Message-ID: <12wxvkghwgpw3.k4qf1rqnppjb$.dlg@40tude.net> (raw)
In-Reply-To: e83d5dc3-8044-4692-b167-da7093555648@googlegroups.com

On Mon, 3 Aug 2015 09:08:15 -0700 (PDT), Serge Robyns wrote:

> I've a design issue with regards to what is the best if not ideal approach
> in building types or classes that refer to each other and could be
> aggregates.
> 
> Lets use an example  I've the following entity:
> 
>    type T_Client is tagged record  -- will be mapped a table
>       Id         : Integer := 0;
>       First_Name : T_Client_Name := T_Client_Name (P_Empty_String);
>       Last_Name  : T_Client_Name := T_Client_Name (P_Empty_String);
>    end record;
> 
> This is to keep track of client info.
> 
> I've the following other entity amongst others.
> 
>    type T_Subscription is tagged record  -- will be mapped to a table
>       Name    : T_Subscriptiont_Name := No_Subscription_Name;
>       Product : T_Product_Name := No_Product_Name;
>       Client  : T_Client := No_Client;   -- Could also be of the same type T_Client.Id, used in different approach.
>       Date    : Ada.Calendar.Time := GNAT.Calendar.No_Time;
>    end record;
> 
> And I've other entities as well that do have similar relationships.

When aggregation does not work, which is the case when relationships are
complex, you keep them outside. You create maps

   Client to [not null access] Subscription
   Subscription to [not null access] Client

etc. And search the maps if you have one and need another. For the map you
can use hash or binary searched container.

Note that aggregation is fragile. If you have a suspicion that
relationships may go chaotic, don't aggregate.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  parent reply	other threads:[~2015-08-03 16:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-03 16:08 Design of cross referring types/classes and proper usage of containers Serge Robyns
2015-08-03 16:14 ` Serge Robyns
2015-08-03 20:17   ` Georg Bauhaus
2015-08-03 16:22 ` Dmitry A. Kazakov [this message]
2015-08-04 11:43   ` Serge Robyns
2015-08-04 12:13     ` Dmitry A. Kazakov
2015-08-04 19:00       ` Serge Robyns
2015-08-04 19:20         ` Jeffrey R. Carter
2015-08-04 20:27         ` Randy Brukardt
2015-08-04 21:21         ` Simon Wright
2015-08-08 11:25           ` Serge Robyns
2015-08-09  3:11             ` Randy Brukardt
2015-08-09 13:33               ` Serge Robyns
2015-08-05  7:37         ` Dmitry A. Kazakov
2015-08-05 17:51           ` Serge Robyns
2015-08-05 19:21             ` Dmitry A. Kazakov
2015-08-06  7:00               ` Georg Bauhaus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox