[4749] in java-interest

home help back first fref pref prev next nref lref last post

Re: HELP - need abstract static variables (no good solution?)

daemon@ATHENA.MIT.EDU (Gary L. Craig)
Fri Jan 12 10:25:01 1996

Date: Fri, 12 Jan 96 08:42:56 EST
From: craig@cat.syr.edu (Gary L. Craig)
To: ranlevy@eandm.co.il
Cc: java-interest@java.Eng.Sun.COM
In-Reply-To: <9601111818.AA11986@draven.Eng.Sun.COM> (ranlevy@eandm.co.il)

In the case of wanting a per class object for all subclasses:

1) Make your "buffer" a true object.   Then your "initData()" method
   gets sucked into the "buffer's" constructor!

2) Use the "Singleton" pattern from the GoF book!   Here instead of
   constructing the buffer at class load time, you create it upon
creating the first object.

There are still problems about needing a per subclass static!   In
general this is a strange design, to use "subclassing" to partition by
data.

A better design is to create:
  ObjectGroupOne  and 
  ObjectGroupTwo

And now have your data var associated with an "instance" of a group
(Collection) object.    Add to this a factory method (again GoF) with
Class.newInstance() and you have the object groups create their own
members!

-- 
Gary L. Craig                                   phone: (315) 443-5936
Superlative Software Solutions, Inc. (3Si)      FAX: (315) 443-4745
2-212 Center for Science and Technology         email: craig@cat.syr.edu   
Syracuse University   Syracuse, NY 13244-4100   http://www.cat.syr.edu/~craig
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post