TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"C. Daniel Cooper" <[log in to unmask]>
Reply To:
C. Daniel Cooper
Date:
Mon, 4 Dec 2000 07:33:49 -0800
Content-Type:
text/plain
Parts/Attachments:
text/plain (29 lines)
Stephane Richard wrote:
> dont stop at telling me this is a bad design.  Contrary to
> popular belief global variables are a bad design pretty much in any
> programming language.  Tell me why it is bad, and how to make it better.

Ok, here's another view on the question: We can think of the five
packages as a cohesive functional group. This is indicated by your
already-considered opinion that the global variable is necessary,
to be shared equally among the five; and presumably (although you
didn't mention it), there are any number of *other* packages in the
application that do *not* (directly) access the global data -- only
the five packages.

This suggests a child hierarchy, where the five packages are children
of a common parent, and the latter declares the data. By making the
data private, you assure that only the children can have visibility,
thus limiting the globalness to only the relevant set of cohesive
packages. This language mechanism allows a higher-order encapsulation,
and as a designer, you can think of the parent and five children as
a sort of a mega-package that supports the remainder of the application.

--

C. Daniel Cooper ==========v=================v=======================v
Adv Computing Technologist | processes       | All opinions are mine |
206-655-3519               | + architectures | and may not represent |
[log in to unmask]  |   = systems     | those of my employer. |
===========================^=================^=======================^

ATOM RSS1 RSS2