| To: | users@xxxxxxxxxx, "Mitchell, John" <jlmitchell@xxxxxxxx> |
|---|---|
| Subject: | Constants imply DP (was: Question on last Monday's meeting) |
| From: | Mark Windholtz <windholtz@xxxxxxxxx> |
| Date: | Fri, 25 Feb 2005 11:39:41 -0500 |
| Delivered-to: | mailing list users@cinjug.org |
| Domainkey-signature: | a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=gAFLEjHCWGElmCCUGuQx3b1QxtUXN7k58CBSpEw+oB7olu+6zHogGLEhbVfMKg5pX/QUYXJJa9z+TsIm5eU3hkQBa44dRoh/13dIWZ8dgsQ1OC2kXFR8cur3cQPGzlSCKKPSq+hCRh/8ivvyTODalGQETpcQ405O+sCWGAqBtkY= |
| In-reply-to: | <CEB8092DFD93924AB120334CEEC4EC3D013247C5@CVGEXCEMAIL001.ga.afginc.com> |
| Mailing-list: | contact users-help@cinjug.org; run by ezmlm |
| References: | <CEB8092DFD93924AB120334CEEC4EC3D013247C5@CVGEXCEMAIL001.ga.afginc.com> |
| Reply-to: | Mark Windholtz <windholtz@xxxxxxxxx> |
Mitchell, John wrote:
>
> If a constant is needed by more than one
> class, what is the alternative?
The question is WHY is it needed by one or more classes?
What is the behavior that needs a constant?
Most likely some "if" statement or "switch" is using it
to choose a list of possible behaviors.
To contain the spread of this kind of conditional logic
is why OO was invented.
A constant is data.
That data is used by other things, called processes.
When a single process needs the constant,
move the constant to the place it is used
and encapsulate it from the world.
When multiple places need the constant, ask why.
Most likely you need a new Object that has behavior
that uses that constant and is called by the various
places that originally directly accessed the constant.
If your frameworks require you to program with lots
of constants question your choice of frameworks.
One step is to put the shared behavior and constant
into a global object.
Global objects are called Singletons.
They also cause trouble, but are still better than
global data (ie. constants) because at least they provide
behavior not just data.
Config files can also be a source of global constant data.
They also should be encapsulated inside objects.
> Feel free to refer me to an article or something.
>
Sorry I havn't written it up yet.
--
Regards,
-Mark
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | RE: [cinjug-users] Question on last Monday's meeting, Mitchell, John |
|---|---|
| Next by Date: | Re: [cinjug-users] Does corp. America still trust Java?, Farhan Shah |
| Previous by Thread: | RE: [cinjug-users] Question on last Monday's meeting, Mitchell, John |
| Next by Thread: | RE: [cinjug-users] Constants imply DP (was: Question on last Monday's meeting), Jim Cook |
| Indexes: | [Date] [Thread] [Top] [All Lists] |