I have a custom NSControl that acts as sort of a two dimensional slider where you can drag a handle around the view. I added a few class specific methods and the only ones I overrode were the mouse actions and drawRect. My question is, how do I get it to implement target action? How can I make it behave like a slider and continuously sen...
How do you create multiple DB connections using Singleton pattern? Or maybe there's better approach, to share the same class but multiple connections?
...
Every time I come across an implementation of the singleton pattern or any static classes (i.e. classes with (almost) only static members) I wonder whether this isn't actually a hack and therefore heavy abuse of the principle of classes and instances just to design single objects instead of designing classes and creating a single instanc...
A few months ago i read about a technique so that if there paramaters you passed in matched the local variables then you could use some short hand syntax to set them. To avoid this:
public string Method(p1, p2, p3)
{
this.p1 = p1;
this.p2 = p2;
this.p3 = p3;
}
Any ideas?
...
In C# how can you find if an object is an instance of certain class but not any of that class’s superclasses?
“is” will return true even if the object is actually from a superclass.
...
I've lately been thinking a lot about alternatives to the class-based approach to object-orientation.
One thing which bugs me in today's languages is that we often use static classes / singletons to design single (global) objects because there isn't any other way to do it, so in my opinion it's rather a hack than a feature.
Another thing...
What's the reason of passing a value for a self reference in class functions in python? For instance:
class MyClass:
"""A simple example class"""
i = 12345
def f(**self**):
return 'hello world'
By doing this, aren't you doing the compiler's work?
...
My TextBox won't update! I am using it as a Log to update what other things are doing...
Form 1 code:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Data.OleDb;
using System.Collections.Specialized;
using System.Tex...
I need to create many classes that are somewhere between integer and enum.
I.e. have the arithmetics of integer but also are not implicitly converted to int.
...
I have a variable on the global scope that is named ${SYSTEM}, where SYSTEM is a defined constant. I've got a lot of classes with functions that need to have access to this variable and I'm finding it annoying declaring global ${SYSTEM}; every single time.
I tried declaring a class variable: public ${SYSTEM} = $GLOBALS[SYSTEM]; but this...
Hi,
you probably know this -- you're going to create some nice class, you think about it a little, maybe even draw a little UML here and there and then you're ready for implementation. You create header files with member functions, maybe even some member properties.
And now comes the dull work -- rewriting everything into .cpp file. It...
Hi all;
I don't know OWNER object class name. So I must check everywhere in my codes like that :
if TObject(OWNER) is TFirstClass then begin
TFirstClass(OWNER).FirstFunction;
TFirstClass(OWNER).SecondFunction;
...
end else
if TObject(OWNER) is TSecondClass then begin
TSecondClass(OWNER).FirstFunction;
TSecondClass(OWNER).Sec...
I have a class.
Public Class Foo
Private _Name As String
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
Private _Age As String
Public Property Age() As String
Get
Retur...
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...
I know this question sounds rather vague so I will make it more clear with an example:
$var = 'bar';
$bar = new {$var}Class('var for __construct()'); //$bar = new barClass('var for __construct()');
This is what I want to do. How would you do it? I could off course use eval() like this:
$var = 'bar';
eval('$bar = new '.$var.'Class(\'v...
In Java, i like to use constructs such as
List<String> list = new ArrayList<String>() {{add("foo");}};
Is there a way to do this in 1 line in C#, too?
...
I tried the following code in codepad.org:
class test {
const TEST = 'testing 123';
function test () {
$testing = 'TEST';
echo self::$testing;
}
}
$class = new test;
And it returned with:
1
2 Fatal error: Access to undeclared static property: test::$testing on line 6
I want to know whether referencing a class const...
Hi, I'm really struggling with something here. I have a class module, let's call it FormMan which has a bunch of methods relating to the large number of userforms I have in my project. One particular method is to be called from a lot of different places and is pretty simple - it simply adds a user defined number of controls to a form and...
When should someone use structs instead of classes or vice versa in C++? I find myself using structs when a full-blown class managing some information seems like overkill but want to indicate the information being contained are all related. I was wondering what are some good guidelines to be able to tell when one is more appropriate th...
whats the difference between them when it comes to css, will it hurt me if i've only been using div id?
i see different developers doing them both ways, and since im self taught, ive never really figured it out
thanks!
...