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=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Design of cross referring types/classes and proper usage of containers Date: Tue, 04 Aug 2015 22:21:44 +0100 Organization: A noiseless patient Spider Message-ID: References: <12wxvkghwgpw3.k4qf1rqnppjb$.dlg@40tude.net> <8b424e66-337a-4943-91d1-e421312b5c95@googlegroups.com> <186o8cox1jqwa.yahqsx8p0k84$.dlg@40tude.net> <3341271b-4926-40cb-a9aa-660522d56f24@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="fbe1d5b0173017f7cc2ccfa8ad3bc8c1"; logging-data="9141"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/EkPLQBCnSMrtN7q7MM2omRG5w/Xy3Alg=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) Cancel-Lock: sha1:llKoZksVwBHi5hQo+SQt1m0pMOI= sha1:W+DOKwnJ4A0sx0AG5sGWvmoxFC8= Xref: news.eternal-september.org comp.lang.ada:27359 Date: 2015-08-04T22:21:44+01:00 List-Id: Serge Robyns writes: > Shall I Storing the full element of objects or references created > through new T_xyz The objects should be limited, in Ada terms; you don't want a copy of a subscription in a client object (in general; I guess if subscriptions have no other relationships .. well, no, a - say, Mailing_List - will in general have many subscribers, and a client will have many subscriptions). In general I'd keep Clients as elements in a Map keyed by client_ID, likewise Mailing_Lists. The limited object in the Map *is* the Client, you can't copy it out and risk confusing the copied info with the thing itself. I'd try to implement a Subscription as a record containing a client_ID and a mailing_list_ID and any supplementary data (renewal date, discount rate ...), and keep them in a Subscription container (classic database stuff). This does leave you to work out how to get efficient access from a specific Client to all the Mailing_Lists that they subscribe to, and vice versa, and you might want to optimise a bit.