comp.lang.ada
 help / color / mirror / Atom feed
From: "Ed Falis" <falis@verizon.net>
Subject: Re: Hiding the value of Constants
Date: Sat, 11 Jul 2009 22:15:25 GMT
Date: 2009-07-11T22:15:25+00:00	[thread overview]
Message-ID: <op.uwxb30pz5afhvo@naropa> (raw)
In-Reply-To: fR76m.109597$d36.74475@bgtnsc04-news.ops.worldnet.att.net

On Sat, 11 Jul 2009 17:53:15 -0400, anon <anon@anon.org> wrote:

> In the years, there has been a few people asking how to hide values or  
> constant.
> Some say use private which the value is still known. Others say use  
> functions
> which can be hidden by removing the source code of the body of the  
> package,
> but requires a call runtime routine each time the value is needed.
>
> But the main problem is that each person who wants to hide a constant  
> forgets
> is that all someone has to do is to write a simple program to print the  
> value.
> So, except to may be getting bonus points from a prof, its a waste of  
> time.
>
> In my example I just showed a third way. To initialize the value at the
> Elaboration time instead of compile or using main runtime.
>
> You need to spead your weekends learning a few ticks of the trade about  
> Ada.
> The program works. Just play with it, you might learn that using  
> functions or
> private section to hide a value is not the only way.

"Information Hiding" is not about hiding information from programmers.   
It's about removing details that are irrelevant to clients of an interface  
to services, in order to give more flexibility to the implementation of a  
service and to make the client code's view of the service as essential as  
possible.  This reduces the need to rewrite client code when the  
implementation of a service is modified.  Tucker Taft had a way of  
characterizing the difference between the public and private parts of  
package specs that I still find appealing:  the public part presents the  
logical interface to client code; the private part presents the physical  
part of the interface that is needed by the compiler for it to be  
efficient (or to deal with extra-language representation issues).  This  
can be contrasted with more extreme approaches to "information hiding"  
that use opaque types in the overall spec, deferring all detail to the  
package body (and so invoking extra indirections).

- Ed



  parent reply	other threads:[~2009-07-11 22:15 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-07  8:48 Hiding the value of Constants Rick
2009-07-07  8:54 ` xavier grave
2009-07-07  8:58   ` AdaMagica
2009-07-07  9:41 ` Georg Bauhaus
2009-07-07 10:41   ` Hibou57 (Yannick Duchêne)
2009-07-07 15:51     ` Adam Beneschan
2009-07-07 16:26       ` Hibou57 (Yannick Duchêne)
2009-07-07 18:48       ` Dmitry A. Kazakov
2009-07-07 19:05         ` Adam Beneschan
2009-07-07 19:53           ` Dmitry A. Kazakov
2009-07-07 20:28             ` Adam Beneschan
2009-07-07 20:57               ` Dmitry A. Kazakov
2009-07-08 10:25                 ` Georg Bauhaus
2009-07-08 12:20                   ` Dmitry A. Kazakov
2009-07-09 23:04 ` anon
2009-07-10  6:37   ` AdaMagica
2009-07-11 19:06     ` anon
2009-07-11 19:26       ` Georg Bauhaus
2009-07-11 21:53         ` anon
2009-07-11 22:03           ` Albrecht Käfer
2009-07-11 22:15           ` Ed Falis [this message]
2009-07-15  9:30             ` anon
2009-07-11 23:31           ` Egil
replies disabled

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