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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.182.165.70 with SMTP id yw6mr9591765obb.33.1438797096689; Wed, 05 Aug 2015 10:51:36 -0700 (PDT) X-Received: by 10.140.31.194 with SMTP id f60mr124071qgf.10.1438797096659; Wed, 05 Aug 2015 10:51:36 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!pg9no7355575igb.0!news-out.google.com!78ni7828qge.1!nntp.google.com!69no4071497qgl.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 5 Aug 2015 10:51:36 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=81.219.20.2; posting-account=6m7axgkAAADBKh082FfZLdYsJ24CXYi5 NNTP-Posting-Host: 81.219.20.2 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> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <46bc62f8-db8d-4e09-88b9-555e4eb285ba@googlegroups.com> Subject: Re: Design of cross referring types/classes and proper usage of containers From: Serge Robyns Injection-Date: Wed, 05 Aug 2015 17:51:36 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:27367 Date: 2015-08-05T10:51:36-07:00 List-Id: On Wednesday, 5 August 2015 09:37:20 UTC+2, Dmitry A. Kazakov wrote: > On Tue, 4 Aug 2015 12:00:28 -0700 (PDT), Serge Robyns wrote: >=20 > > Given static (immutable data) one one hand and dynamic data (changed > > during the execution) on the other hand; stored in various containers.= =20 > > What is actually the best approach? Shall I Storing the full element of > > objects or references created through new T_xyz? >=20 > That depends on the semantics of mutators. If the semantics is referentia= l, > e.g. you change the object in one place and all logical references get > aware of the change, the only way (that does not involve global variables > and distributed overhead) is having physical references. I've indeed two instances of such objects so far. This allows me to use a = "setter" like Obj.Change (Value), once I've pulled them from on of the cont= ainers (through indirection). (BTW I do love the Ada 2012 changes to conta= iners.) In my first attempt, I stored them in their referring object throu= gh an access type (for speed), now I'm storing their key in their referring= object and use it to find them in their respective containers. I've been = thinking on returning a Cursor but then I'm exposing the implementation and= require to put the container definition into the specification package of = the package building the these containers. My end goal is to use a Proxy pattern, allowing the data to be retrieved fr= om a XML file (ideal for test automation) or from a database (in production= mode). In the case of the XML file, the whole data gets loaded at once in= to containers, whereas for a database approach, specific SQL statements wil= l retrieve the data by these proxies. The users of the objects shouldn't n= otice the implementation. >=20 > Things like MVC require referential semantics. >=20 > > Shall I Storing the full element of > > objects or references created through new T_xyz? >=20 > You could have a constructing function that hides ugly allocator. E.g. wh= en > using strong references you might have: >=20 > function Create (...) return Handle; >=20 > which internally allocates some private limited object the tagged Handle > points to. Handle can be copied around and stored into a container. [*] >=20 Limited objects is one of these things I'm struggling getting my head aroun= d. I will need to (re)read about it to fully understand their purpose as f= or now I perceive them as a pain.