comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: What is your opinion on Global Objects?
Date: Tue, 18 Nov 2014 20:03:27 -0700
Date: 2014-11-18T20:03:27-07:00	[thread overview]
Message-ID: <m4h19j$l1v$1@dont-email.me> (raw)
In-Reply-To: <OzTaw.281638$lO7.189293@fx26.iad>

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.

-- 
Jeff Carter
"You empty-headed animal-food-trough wiper."
Monty Python & the Holy Grail
04

  reply	other threads:[~2014-11-19  3:03 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-18  1:36 What is your opinion on Global Objects? Hubert
2014-11-18  2:52 ` Jeffrey Carter
2014-11-18  3:08   ` Hubert
2014-11-18  3:16     ` Shark8
2014-11-18  5:09     ` Jeffrey Carter
2014-11-18 11:23     ` Brian Drummond
2014-11-19  2:50       ` Hubert
2014-11-19  3:03         ` Jeffrey Carter [this message]
2014-11-19  9:13           ` Hubert
2014-11-19 10:22             ` J-P. Rosen
2014-11-19 17:37             ` Jeffrey Carter
2014-11-20 16:34         ` Stephen Leake
2014-11-20 21:11           ` Adam Beneschan
2014-11-21 15:25             ` Stephen Leake
2014-11-21 21:53             ` Randy Brukardt
2014-11-21  1:25           ` Hubert
2014-11-21  3:00           ` Brad Moore
2014-11-19 10:11   ` Jacob Sparre Andersen
2014-11-20  6:21     ` Hubert
2014-11-18  8:54 ` Dmitry A. Kazakov
2014-11-20 20:33 ` sbelmont700
2014-11-20 21:35   ` J-P. Rosen
2014-11-21  1:02     ` sbelmont700
2014-11-21  1:31       ` Hubert
2014-11-21  9:01     ` Dmitry A. Kazakov
2014-11-22  7:46       ` J-P. Rosen
2014-11-22  9:02         ` Dmitry A. Kazakov
replies disabled

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