Hello,
Is it possible to create a class dynamically by reading an xml file ( in java preferably) ? if yes, please provide pointers on how to do it.
In the process of development, we have come up with a class that has 5 attributes, all these attributes correspond to an entry in the xml file, now if the user adds/modifies the xml entry...
Hello,
im trying to understand php constructor and destructor behaviour. Everything goes as expected with the constructor but i am having trouble getting the destructor to fire implicitly. Ive done all the reading on php.net and related sites, but i cant find an answer to this question.
If i have a simple class, something like:
class ...
I have a few classes: SomeClass1, SomeClass2.
How can I create a new instance of one of these classes by using the class name from a string?
Normally, I would do:
var someClass1 = new SomeClass1();
How can I create this instance from the following:
var className = "SomeClass1";
I am assuming I should use Type.GetType() or someth...
I have read about pointers to class members, but I have never seen them being used in any practical applications. Can someone explain what are the use cases of such pointers? Is it really necessary to have such pointers?
Eg.
class abc
{
public:
int a;
abc(int val) { a = val; }
};
int main()
{
int abc::*data;
abc obj(5)...
Hi,
Is it possible to get the variable name used to reference an instantiated class from within the class? here's an example of what i mean:
class Test {
function getName(){
//some code here to get the name '$test1' in this example
}
}
$test1 = new Test
It's not a must for this to be possible, but it'd help for a project ...
Is there way for a class to 'remove' methods that it has inherited?
eg. If I don't want my class to have a ToString() method can I do something so that it is no longer available?
...
In the following code:
<script type="text/javascript">
var i = 10;
function Circle(radius) {
this.r = radius;
this.i = radius;
}
Circle.i = 123;
Circle.prototype.area = function() { alert(i); }
var c = new Circle(1);
var a = c.area();
</script>...
Hi friends, my requirement - suppose I have three classes namely Employee, Customer and Department. Employee contains attributes id, name, dept. Customer contains id and name. Department contains id and name. Now all three class have common functionality i.e. create, update and delete. I want to implement these functions using an interfa...
what is best way to model many-to-many relationship?
lets say we have a two classes , Team and Player
any given Player can be in multiple Team s
any Team can have as many Player s as they like
I like to call methods like
playerX.getTeamList() to get the list of all the Team s he/she is in
teamY.getPlayerList() to get the list of ...
I want to use observer pattern for a logging system.
We have got logObservers and logObservables.
The class that will have to log something will implement iLogObservable and include these methods:
private $logObservers = array();
public function addLogObserver($logObserver) {
$this->logObservers[] = $logObserver;
}
public functio...
I want a class property to be reference to another class, not its object and then use this property to call the class's static methods.
class Database {
private static $log;
public static function addLog($LogClass) {
self::$log = $LogClass;
}
public static function log() {
self::$log::write(); // seems ...
Whenever I create a PHP library (not a framework) I tend to reinvent everything every time.
"Where to put configuration options?"
"Which design pattern to use here?"
"How should all the classes extend each other?"
and so on...
Then I think, isn't there a good library framework to use anywhere?
It's like a framework for a web applic...
If anyone familiar with Rebecca Wirfs-Brock, she has a piece of Java code found in her book titled, Object Design: Roles, Responsibilities, and Collaborations.
Here is the quote >Applying Double Dispatch to a Specific Problem
To implement the game Rock, Paper, Scissors we need to write code that determines whether
one object “beats” ano...
Hi,
What would the basic C# code look like to model a many-to-many relationship, where the relationship itself has attributes? And also in this case the many-to-many was referential. So a possible database model for this might look like the following (just to give an example of what I'm talking about)
Nodes
ID
Name
Description
Rel...
What is faster: writing PHP code using functions or writing it as pure script? So, as I see it Apache or any other server will create from PHP code using functions a pure script... I mean we had:
function foo($a, $b){ return ($a + $b); }
echo foo(4, 5);
and PHP will turn it into something like:
echo 9;
Or will it?
...
Suppose I have class animal and classes cat and dog extending it. I want to do something along the lines of:
foreach (class a in {cat, dog})
if (a.isValid(parameters))
doStuff();
isValid is a static method from animal that just checks if the given parameters define an object of the given type
doStuff means I'm doing stuf...
Normally, I've seen prototype functions declared outside the class definition, like this:
function Container(param) {
this.member = param;
}
Container.prototype.stamp = function (string) {
return this.member + string;
}
var container1 = new Container('A');
alert(container1.member);
alert(container1.stamp('X'));
This code prod...
i have seen a lot of coders choosing this filename convention:
file.class.php.
is this a standard of naming class files?
just curious. so i know if i should follow it for all class files in the future.
thanks
...
here is my setup.
class testA {
function doSomething() {
return something;
}
}
$classA = new testA();
class testB {
$classA->doSomething();
}
this wont work inside that class.: $classA->doSomething();
how else would i do it?
...
consider a standard c# 'function'
public void foo()
{
//some code
}
In c or c++ this is called a 'function' - even if taking no parameters and returning no value. In another language maybe it would be a 'procedure'.
In object orientation speak it would be called a 'method' if a class member.
What would be the correct term to use in c#?...