in reply to how to make a universally inherited method?
If so, how does using a Singleton class help at all? In order to keep the app working, all parts of your app will need access to the singleton. So that in itself will not help. The code is still tweaking a hairy collection of state, only now it is wrapped up in a singleton. I don't see any benefit yet.
You want to migrate. So you plan to move data out of the singleton/global variables into managed packages/objects. Good.
I guess that encapsulation in the singleton gives you the ability to move the data out from the singleton to a new class, as long as you change the implementation of the singleton to access the new class. But that doesn't help your code quality, since all the code which accesses the data still does so through the singleton.
Code quality benefits only accrue once you change the code which accesses the data to do so through the new interface. At which point you will presumably remove that data from the singleton.
But but but. The hard part is changing all the code which uses the data. AFAICS, you propose to do this twice - once to access the singleton and then once to access the 'new interface'.
Why not just leave the old, global-accessing code in place with a view to getting it to use the new interface when it is ready (note that you can do this piecemeal, as you finish each new interface which encompasses part of your global data)? OK, you may have namespace issues (your globals will reside in main::) but they can be hacked around fairly easily by aliasing (a hopefully-temporary 'use Crud' in each new package). The namespace pollution will probably be horrible but you have that already.
OK. I should probably go away and read up on design patterns, but this is an honest question. Can someone explain the benefits to me please?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: how to make a universally inherited method?
by dragonchild (Archbishop) on Nov 29, 2001 at 19:08 UTC | |
by exphysicist (Sexton) on Nov 30, 2001 at 08:37 UTC | |
|
Re: Re: how to make a universally inherited method?
by lachoy (Parson) on Nov 29, 2001 at 18:33 UTC |