Multiple DB connection class
How do you create multiple DB connections using Singleton pattern? Or maybe there's better approach, to share the same class but multiple connections? ...
How do you create multiple DB connections using Singleton pattern? Or maybe there's better approach, to share the same class but multiple connections? ...
I'm trying to figure out how to best lay this out. I'll explain what I have now, but I'm wondering if there is a better way to do this. I have a class Section that has basic properties: Name, Description, et.al. I use a list of Sections for the users to choose from. They can add a Section as many times as they want to a Parent object an...
Hello! I'm trying to make a Tetris-like game in XNA, and currently I'm thinking of what way would be the best to handle it. This is what I have so far: I have a class called Block, which has for example texture and color tint. Then I was planning on having everything in a double array, like: Block[,] blocks = new Block[10,20]; which...
This is what I've come up with as a method on a class inherited by many of my other classes. The idea is that it allows the simple comparison between properties of Objects of the same Type. Now, this does work - but in the interest of improving the quality of my code I thought I'd throw it out for scrutiny. How can it be better/more eff...
[Edit:] Earlier I asked this as a perhaps poorly-framed question about when to use OOP versus when to use procedural programming - some responses implied I was asking for help understanding OOP. On the contrary, I have used OOP a lot but want to know when to use a procedural approach. Judging by the responses, I take it that there is a f...
I have 3 classes in different files: X | ------- | | Y Z I will be creating several objects of inherited classes Y and Z. A specific function in class Z should be executed only if some flag variable is set by class Y. Where should I create this flag variable (which class) and what should be the declaration be like (sta...
By putting functionality into a function, does that alone constitute an example of encapsulation or do you need to use objects to have encapsulation? I'm trying to understand the concept of encapsulation. What I thought was if I go from something like this: n = n + 1 which is executed out in the wild as part of a big body of code and ...
Ok, so having given up on getting the built in .NET configuration system to save/load data about a custom object per user, I have moved to using a serializable object. And, to go a step further, I'd like to bind it to my controls in the options window of my application. Please forgive the length of this question as it has some chunks of...
I'm looking into converting a flash app I have into Javascript but was told that it probably wouldn't be possible due to the number of objects I would have to have on the go. Can anyone tell me if this is true and, if it is, what the limits are? TIA, Urf ...
Hi, I have some software that is heavily dependent on MySQL, and is written in python without any class definitions. For performance reasons, and because the database is really just being used to store and retrieve large amounts of data, I'd like to convert this to an object-oriented python script that does not use the database at all. ...
I have a small program where I have been trying to create collections of a particular object I have created (Job). Regardless of whether I am using an array, collection or list, each time I add a new instance of the object to the array/collection/list, it overwrites all previous items with the same object. For example, let's say Job ha...
I have an array of objects, something like this: var myArray = [ { 'name' : 'some name', id: 23131, 'has' : ['dogs'] }, { 'name' : 'some name 2', id: 8678, 'has' : ['dogs', 'cats'] }, { 'name' : 'some name 3', id: 2125 , 'has' : ['donkeys', 'goats']}, { 'name' : 'some name 4', id: 90867, 'has' : ['parrots', 'treasure'] }, ...
I need to make some custom objects in VBA that will need to reference each other and I have a some issues. First - how do object constructors work in VBA? Are there constructors? Second - are there destructors? How does VBA handle the end of the object lifecycle? If I have an object that references others (and this is their only refere...
I use Delphi, but this is a question that I think is valid for any object-oriented programming language. When should I use records over objects. I used to think that you used records when you had some simple definition of a set of related data that you wanted to store together that didn't need to be able to manipulate itself. However e...
I have a Javascript class that contains a few functions and member objects: function MyUtils() { // Member Variables (Constructor) var x = GetComplexData(); var y = DoSomeInitialization(); // Objects this.ParamHash = function() { // Member variables this.length = 0; this.items = new Array(); // Constructor ...
When using class files in Ruby, do you put the 'requires' statements at the top of the file, or inside the class definition? ...
I am currently working on some code with which I am having some trouble. I have two buttons on a GUI. If one button is pressed it assigns a value to a string a value to reflect this. The other button is the same except that a different value is assigned to the string. This String is created at the beginning before the constructor in...
I'm trying to create an object in a function, but I am running into the problem that variable names have to be defined at runtime. Is there something I can do like with arrays that allows ne to dynamically create a variable in a function and preferably give it a different name from the one created when the function was called last? ***I...
Application Background Our platform is a click-once WPF application. We have a "shell" that contains a navigation menu structure and it hosts our own custom "page" classes. When you navigate to a new page, we swap out the content of the shell (essentially). Problem So, I work for a company that is working on a extremely large softwar...
Hey everyone, I am trying to wrap my mind around something in java. When I pass an object to another class' method, can I not just call any methods inherent to that object class? What is the reason code such as the example below does not compile? Thank you, class a { public static void myMethod(Object myObj) { myObj.testing();...