From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: buffer1.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!news.mixmin.net!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Design of cross referring types/classes and proper usage of containers Date: Mon, 3 Aug 2015 18:22:18 +0200 Organization: cbb software GmbH Message-ID: <12wxvkghwgpw3.k4qf1rqnppjb$.dlg@40tude.net> References: Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: PhKGQ8B653xps5WLlp7Tcg.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: number.nntp.giganews.com comp.lang.ada:194651 Date: 2015-08-03T18:22:18+02:00 List-Id: 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