comp.lang.ada
 help / color / mirror / Atom feed
From: Dr Nancy's Sweetie <kilroy@elvis.rowan.edu>
Subject: Re: Good Ada Style For Impossible Actions?
Date: Tue, 29 Oct 2002 01:35:45 GMT
Date: 2002-10-29T01:35:45+00:00	[thread overview]
Message-ID: <RBlv9.20110$T_.487390@iad-read.news.verio.net> (raw)
In-Reply-To: ayev9.145220$%d2.51924@sccrnsc01

Discussing a style question I had involving a program I've been
fiddling with, "tmoran@acm.org" wrote:
> A mouse outside a particular screen area is not an impossible action.

No, but translating the physical position into a logical position is,
if the mouse is outside a certain area.


In any case, I've been thinking about this, and I decided that the
problem was one of incorrect object boundaries.  That is, I had worked
out a "display" object, to handle drawing on the screen, but left all
the keyboard/mouse handling in the main body of the code.

I have since decided that I what I want is to move input management into
the same module with the display, and create an "interface" object.  The
main body of the code will look something this:

   while not Finished loop
      Selection = Interface.Get_Action;

      case Selection.Action is
         when Register_Move =>
            New_Spot := Selection.Spot;
            -- do stuff
         when Exit_Game =>
            Finished := True;
         -- and so on
      end case;
   end loop;

I thought of this because it occurred that a GUI made with GtkAda might
be interesting, but such a thing could never be added into the program
as it was.  This way, I can write the main body of the code so that it
works with an object called "Interface", and I can write a simple text
interface now, and (if I want) add in a fancier one later without having
to change any of the logic.

At least, I think I can.  Having a single variable which points to
different kinds of objects at different times feels like it ought to be
possible, but I haven't read that section of the book yet.

(I did read about protected classes, so I have a working clock.)


Darren Provine ! kilroy@elvis.rowan.edu ! http://www.rowan.edu/~kilroy
"Had George III been a Scheme programmer, he might have responded to
 Patrick Henry by freeing him and then killing him." -- Michael Eisenberg



  reply	other threads:[~2002-10-29  1:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-26 15:59 Good Ada Style For Impossible Actions? Dr Nancy's Sweetie
2002-10-26 21:11 ` Jeffrey Carter
2002-10-28  3:52   ` Dr Nancy's Sweetie
2002-10-28 17:13     ` Jeffrey Carter
2002-10-28 17:33       ` tmoran
2002-10-29  1:35         ` Dr Nancy's Sweetie [this message]
2002-10-28 17:52       ` Warren W. Gay VE3WWG
replies disabled

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