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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ea2b3498720dfde1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-28 17:42:20 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!HSNX.atgi.net!sjc-peer.news.verio.net!news.verio.net!iad-read.news.verio.net.POSTED!not-for-mail From: Dr Nancy's Sweetie Subject: Re: Good Ada Style For Impossible Actions? Newsgroups: comp.lang.ada References: <3DBD7066.1040205@acm.org> Organization: Rowan College of New Jersey User-Agent: tin/1.4.6-20020816 ("Aerials") (UNIX) (SunOS/5.8 (sun4u)) Message-ID: Date: Tue, 29 Oct 2002 01:35:45 GMT NNTP-Posting-Host: 150.250.64.69 X-Complaints-To: abuse@verio.net X-Trace: iad-read.news.verio.net 1035855345 150.250.64.69 (Tue, 29 Oct 2002 01:35:45 GMT) NNTP-Posting-Date: Tue, 29 Oct 2002 01:35:45 GMT Xref: archiver1.google.com comp.lang.ada:30194 Date: 2002-10-29T01:35:45+00:00 List-Id: 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