Hi!
I'm trying my hand at TDD with PHP and am writing a webbased app to access articles in a MySQL database; this is the test function:
class TestArticleTestCase extends UnitTestCase {
...
public function testArticleGenerateInsertSqlString() {
$testArticle = new Article("12345", "2009-09-13 20:20:20", "Test heading", "Test text")...
Recently I've faced a question : How to avoid instantiating a Java class?
However, I answered by saying:
If you don't want to instantiate a class, use "abstract" modifier. Ex: javax.servlet.HttpServlet, is declared as abstract(though none of its methods are abstract) to avoid instantiation.
Declare a no argument private constructor.
...
How do you access Library items from classes other than the document class?
For example, if I create a movie clip in Flash and Export it for Actionscript with the name Foo, I can do this in the document class:
var f = new Foo();
this.addChild(f);
And it appears on the stage, as it should. But I need to be able to create other instanc...
In other words, why would you need an instance initializer? What difference or advantage do you have in writing a instance initializer over a constructor?
...
Hi all
Just wondering if you're able to help me with my problem. This has probably come about by my not knowing the right keywords to search for.
This is not homework, just anonymised...
I have an interface and a bunch of implementing classes:
interface Fruit
Banana implements Fruit
Apple implements Fruit
....
I have a Fruit ...
I've seen a few questions on this topic, but I haven't been able to find a definitive answer.
I would like to know the proper way to use old-style classes in a new Python code base. Let's say for example that I have two fixed classes, A and B. If I want to subclass A and B, and convert to new-style classes (A2 and B2), this works. Howe...
In Java, one can create instances of a class without actually calling a declared constructor by retrieving one via sun.reflect.ReflectionFactor.newConstructorForSerialization().
As far as I know, this special constructor is called "munged". Where does this term come from? I could not find it in any dictionary.
...
I have a container view that looks something like this
<UserControl x:Class="Views.ContainerView">
<UserControl.Resources>
<ResourceDictionary>
<DataTemplate DataType="{x:Type viewmodels:AViewModel}">
<views:MyView />
</DataTemplate>
<DataTemplate DataType="{x:Type viewmodels:BViewModel}">
<views:MyView />
</DataT...
I have a factory that is supposed to create objects that inherit from class Foo at run-time. I would think that System.Activator.CreateInstance's return type was the same as the type of an object it's creating, but judging from the following error message, its return type is Object.
Error 1 Cannot implicitly convert type 'object' to ...
according to
http://msdn.microsoft.com/en-us/library/ms524620.aspx
you should use server.createObject
If you are already familiar with VBScript or JScript, note that you do not use the scripting language's function for creating a new object instance (CreateObject in VBScript or New in JScript). You must use the ASP Server.CreateObj...
This is something that has been bugging me since I took up AS3 a year ago.
Example. I make a class that extends a Movie Clip and call it "LoaderBar" all it is is some text that says "Loading" and below it another movie clip that is a plain rectangle that I call "lBar"
When I call a function to load my image I add the Loader to the st...
In Javascript it would be:
var newObject = { 'propertyName' : 'propertyValue' };
How to do it in Python?
...
In Karl Seguin's Foundations of Programming there is a small section on using the factory pattern. He closes the passage by stating "you can accomplish the same functionality with constructor overloading", but doesn't indicate when or why?
So,when does it make more sense to use the factory pattern rather than an overloaded constructor ...
I need to perform certain operations on a class after it was unmarshalled
(after it is constructed by JAXB, rather then by myself).
Is there such a functionality in JAXB?
If not, how could I achieve it?
...
Hi, I get the following error with the code below.
expected constructor, destructor, or type conversion before '=' token
--
#include <string>
#include <map>
class Foo {
};
std::map<std::string, Foo> map;
map["bar"] = Foo();
int main()
{
return 0;
}
...
I'm working with a OPC Server control that stores data tags as variant types, described by System.Runtime.InteropServices.VarEnum. These types include the following, VT_BSTR (string), VT_I2 (short) and VT_I4 (long).
All these values are stored by the server as objects and then I have to cast to the correct value when I fetch them.
I kn...
How do I self-instantiate a Java class? I should not use any file other than its class file. Also assume that after the line where I initialized the NAME variable, they don't know the name of the class during compile-time.
Example:
public class Foo implements Bar {
public static final String NAME = "Foo";
private void instanti...
The code below produces this output fine:
This is page one.
This is page two.
But how do I change it so that the PageItem objects are instantiated dynamically from the List<string>?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestInstant
{
class Program
{
static voi...
I have a simple component I created which I instantiate in my main program like so:
newMessage = new MessageDetail();
newMessage.body.text = "Hello World";
I receive the error "Cannot access a property or method of a null object reference" on the second line because newMessage was not fully created prior to hitting the second line of ...
Hi,
I would like to create an instance of a specified class using its name. My code is shown below.
I get a compiler warning. Am I doing this the right way? Is it even possible to use the name of a class and get an instance of that type back, as I don't think there is any way of the compiler knowing what the type should be?
public sta...