So here's my problem...
Let's say I have a simple "Person" class just with "FirstName" and "LastName" attributes.
I want to have a form where the user says how many "Persons" he wants to create and then he fills the name for each one.
E.g. user wants to create 20 persons... he puts 20 on a box clicks the button and starts writing nam...
I am writing a logging service for one of my applications but I am sure many other applications would use this. In that case, would it make sense to make the application extend a class and have all my logging enabled by default (because some logging like application entry point and exit point are required at any cost) in the original cla...
Short summary: When you want to predefine certain instantiations of a class, is it better to create subclasses or a factory?
Problem Context
I have a view helper class MyWebserviceUrl that has a bunch of properties. It's purpose is to generate an url.
I would like to be able to have preconfigured instances of this class, so that I do...
hi,
my compiler is torturing me with this instantiation error which I completely don't understand.
i have template class listItem:
template <class T>
class tListItem{
public:
tListItem(T t){tData=t; next=0;}
tListItem *next;
T data(){return tData;}
private:
T tData;
};
if i try to initialize an object of ...
Take this skeleton class that someone wants to fill in to fetch RSS streams on a series of web sites:
public class RSSStream extends Thread {
public RSSStream(String rssStreamName,String rssURL,int refreshTime){
// constructor code goes here
}
}
Now, let's consider that refreshTime has to be higher than zero and that rss...
Whenever I create a UIElement in code behind, I'd do something like this:
Button button = new Button();
button.Content = "Click Me!";
But then I saw this syntax somewhere, and wanted to know what it's called. I haven't ever seen it used in any of my .NET books:
Button button = new Button { Content="Click Me!" };
This is obviously ...
I have many html forms referring to many persistence classes.
All the html forms are generated by one single class HTMLForm by passing in the respective HTMLFields instances:
public class HTMLForm<T>{
HTMLForm(HTMLFields[] f, Class<T> classt){
this.stupidSunWontAllowTnewInstance = classt;
// ... whatever GWT jazz ....
}
public...
Hi,
My full code is too long, but here is a snippet that will reflect the essence of my problem:
class BPCFGParser {
public:
...
...
class Edge {
...
...
};
class ActiveEquivClass {
...
...
};
class PassiveEquivClass {
...
...
};
struct EqActiveEquivClass {
...
...
};
struc...
var foo = (function() {
var proxy = {},
warning = false;
proxy.warn = function(msg) {
if (!warning) {
warning = true;
alert(msg);
}
return this; //For the purpose of method chaining we return proxy object.
}
function func() {
alert(warning); //This is a pri...
Hey.
I've always assumed that - in the absence of constructor parameters - the parenthesis (curly brackets) follow the class name when creating a class instance, were optional, and that you could include or exclude them at your own personal whim.
That these two statements were equal:
$foo = new bar;
$foo = new bar();
Am I right? Or ...
Hey guys,
Im having a problem with using a variable as the class name when calling a static function within the class. My code is as follows:
class test {
static function getInstance() {
return new test();
}
}
$className = "test";
$test = $className::getInstance();
Ive got to define the class name to a variable a...
This is kinda theoretical question,
I was looking at someone else' code (below) and my simple solution was to instantiate the collection outside linq, but I can guess there will be cases where I'd want to instantiate the objects inside the query, and perhaps only on a selection of elements.
Here's a simplified example of how this was be...
Hi,
I am trying to do this:
public class BaseTable<T extends TableEntry>
{
protected int mRows;
protected int mCols;
protected ArrayList<T> mEntries;
public BaseTable(int rows, int cols)
{
mRows = rows;
mCols = cols;
mEntries = new ArrayList<T>();
for (int i = 0; i < rows; i++)
...
I have encountered various classes that don't allow creation of their instance directly. Rather we have to create their instance from some other class's static method or it own static method. For example:
B b = A.getB();
or
B b = B.getInstance();
What reason is behind that?
Why don't they allow creating instance directly, as in:
...
I have a number of GUI dialogs defined using MXML. Assuming these mxml objects have been compiled into my application, is there any way to instantiate these objects using ActionScript, sort of like this?
myFoo: Mxml2ActionScriptClass("FOO.mxml") = new AutomagicalMXMLFactory( "FOO.mxml");
myFoo.addEventListener(etc etc)
th...
See title. I have a template. I want to force a particular instance of a template to instantiate. How do I do this?
More specifically, can you force an abstract template class to instantiate?
...
As part of a larger application, I am writing a settings class, which collects and stores user-defined settings. This class is a singleton, and is instantiated during application startup.
In order to accept user input, two different GUI frames are insantiated from within ConfigSettings.java, from a public static method, selectSettings(...
I have a simple question: what's the advantage of instantiating a C# delegate as opposed to just passing the function reference? What I mean is:
Why do:
Thread t = new Thread(new ThreadStart(SomeObject.SomeMethod));
When you can do:
Thread t = new Thread(SomeObject.SomeMethod);
Both will compile and work in my experience...am I m...
This is a sort of design question, and I'm sure there are people who do it both ways. But in your opinion, is it better to assign a variable in the class or in the constructor? For example (regardless of syntax or language, this is just to explain):
public class Example
{
private final int TIME_STAMP = Now();
private int num = 2;
...
How to solve the problem of composing a Controller class in PHP, which should be:
easily testable by employing Dependency Injection,
provide shared objects for end programmer
provide a way to load new user libraries
Look down, for controller instantiation with a Dependency injection framework
The problem is, that derived Controll...