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!feeder.eternal-september.org!news.glorb.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!fx27.iad.POSTED!not-for-mail From: Hubert User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: What is your opinion on Global Objects? References: In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Antivirus: avast! (VPS 141118-2, 11/18/2014), Outbound message X-Antivirus-Status: Clean Message-ID: X-Complaints-To: abuse@newsdemon.com NNTP-Posting-Date: Wed, 19 Nov 2014 09:13:20 UTC Organization: http://www.NewsDemon.com Date: Wed, 19 Nov 2014 01:13:17 -0800 X-Received-Bytes: 3015 X-Received-Body-CRC: 711404517 Xref: news.eternal-september.org comp.lang.ada:23542 Date: 2014-11-19T01:13:17-08:00 List-Id: On 11/18/2014 19:03 PM, Jeffrey Carter wrote: > On 11/18/2014 07:50 PM, Hubert wrote: >> That basically is a vote for global objects. Whether they are accessed through a >> global variable or some sort of getter function that returns access > > Most of us on here are talking about how to do it in Ada. However you do it in > C++ will be different, because C++ lacks modules. In Ada, there would be no > functions that return access. > > At some point you have some requirements for your game, and somewhere in them is > something along the lines of "the game will keep track of this, that, and the > other". > > In the design you make from these reqs you decide to meet this req with a DB > object. It allows you to add new (Key, Value) pairs, update the value for a key, > retrieve the value for a key, and delete the pair for a key. > > In the Ada implementation, you implement this object as a package: > > package Game.DB is > procedure Add (Key : in Key_Value; Value : in Data_Value); > > procedure Update (Key : in Key_Value; Value : in Data_Value); > > function Value (Key : in Key_Value) return Data_Value; > > procedure Delete (Key : in Key_Value); > end Game.DB; > > [I'm sure the reality is more complicated. No doubt there are many different > kinds of (Key, Value) pairs.] > > This pkg would be part of a low-level layer in your S/W architecture. Anything > in higher layers that needs to access the DB can with the pkg and call its > subprograms. > > This is the "Package as Object" pattern in Ada. > Ok this is still an access of the global object directly from a subprogram. The subprogram then accesses the variable with the data ijnternally which is the same as accessing a global object. The data object itself is not passed through the parameters of the subprogram that uses it. Sounds like most people are in favor of that method --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com