FROM : j o a r
DATE : Thu Apr 07 08:20:11 2005
On 7 apr 2005, at 03.38, Daniel Hazelbaker wrote:
> That may be what I have to do, but as I said I had never
> expected to do this, and even had decided against it as an option
> but now people are requesting the ability to do so. So I have a
> bunch of global arrays that handle caching and other globals and
> references to globals that I would have to replace and recode to be
> instance specific. For example, there are about 30 classes that
> reference a global pointer to the "main server" instance a few
> dozen times each. Most of these classes use class methods to load
> an object from the database and re-link ID-pointers to other
> objects. So it is not an easy task to convert this to be instance
> specific. In retrospect I can see that was probably not the best
> coding practice, but well.. here I am. :)
That's one reason why global variables are often frowned upon in OOP.
If you had used the singleton pattern, for the same effect, the work
involved in changing from singleton -> multiple instance pattern
would probably have been much smaller.
> However, from the responses I have gotten off-list as well it
> is looking like there is no "decent" solution to this and I need to
> rewrite the portions of code that are globalized and come up with a
> optimized way to make them instance specific.
I don't agree that there should be no "decent" solution to this
problem. To me it sounds like a pretty common problem area, and one
that you could probably solve in many different, all wholly decent,
ways. OTOH, when you say decent, perhaps you mean that there is no
easy way to do what you want to do without a re-write, in which case
I would have to agree.
j o a r
DATE : Thu Apr 07 08:20:11 2005
On 7 apr 2005, at 03.38, Daniel Hazelbaker wrote:
> That may be what I have to do, but as I said I had never
> expected to do this, and even had decided against it as an option
> but now people are requesting the ability to do so. So I have a
> bunch of global arrays that handle caching and other globals and
> references to globals that I would have to replace and recode to be
> instance specific. For example, there are about 30 classes that
> reference a global pointer to the "main server" instance a few
> dozen times each. Most of these classes use class methods to load
> an object from the database and re-link ID-pointers to other
> objects. So it is not an easy task to convert this to be instance
> specific. In retrospect I can see that was probably not the best
> coding practice, but well.. here I am. :)
That's one reason why global variables are often frowned upon in OOP.
If you had used the singleton pattern, for the same effect, the work
involved in changing from singleton -> multiple instance pattern
would probably have been much smaller.
> However, from the responses I have gotten off-list as well it
> is looking like there is no "decent" solution to this and I need to
> rewrite the portions of code that are globalized and come up with a
> optimized way to make them instance specific.
I don't agree that there should be no "decent" solution to this
problem. To me it sounds like a pretty common problem area, and one
that you could probably solve in many different, all wholly decent,
ways. OTOH, when you say decent, perhaps you mean that there is no
easy way to do what you want to do without a re-write, in which case
I would have to agree.
j o a r
| Related mails | Author | Date |
|---|---|---|
| Daniel Hazelbaker | Apr 6, 21:02 | |
| Dave Rehring | Apr 6, 21:36 | |
| j o a r | Apr 6, 22:10 | |
| Daniel Hazelbaker | Apr 7, 03:38 | |
| j o a r | Apr 7, 08:20 | |
| Jonathon Mah | Apr 7, 08:52 |






Cocoa mail archive

