General > Off Topic

Personal news

<< < (6/7) > >>

Botsareus:
Is there anything that could be done with the global variables in DB2 other than changing most of the architecture?

Panda:

--- Quote from: Botsareus on March 31, 2016, 03:04:52 PM ---Is there anything that could be done with the global variables in DB2 other than changing most of the architecture?

--- End quote ---
Not without tests, really!

Peter:

Botsareus:
I get tests.
What I am really asking is mechanics of stuff like this.
The only experience with fully object oriented programming I had was an old XNA book which I never finished reading because I found "Black Art of 3D game programming" to be a far more interesting read. And than XNA got replaced with Unity.

Panda:
One way to do it, and probably the most like a conventional global variable, would be to use the Singleton pattern. https://en.wikipedia.org/wiki/Singleton_pattern This is NOT my favourite way to do it.

Another way of doing it would be "giving" each part of the program that needs what was a global variable or a set of them, an instance of a holder for it. i.e.

--- Code: ---class PreviouslyGlobal {
  private int variable1;
  private int variable2;
  ...
}

class Component1 {
   private PreviouslyGlobal vars;
   
   public Component1(PreviouslyGlobal vars) {
       this.vars = vars;
   }
}

class Component2 {
   private PreviouslyGlobal vars;
   
   public Component2(PreviouslyGlobal vars) {
       this.vars = vars;
   }
}

class Driver {
   void main() {
       PreviouslyGlobal sharedVars = new PreviouslyGlobal();
       Component1 c1 = new Component1(sharedVars);
       Component2 c2 = new Component2(sharedVars);
   }
}


--- End code ---

I'm not exactly sure how these would be implemented in VB6.

These are both certain ways of doing it, although not the way of doing it.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version