Hi,
I'm trying to make some kind of function that loads and instantiates a class from a given variable. Something like this:
<?php
function loadClass($class) {
$sClassPath = SYSPATH."/classes/{$class}.php";
if (file_exists($sClassPath)) {
require_once($sClassPath);
$class = $class::getInstance();
}
}
?>
If I use it like...
I am trying to create an object that is capable of handling query-like conditional statements. This is so I can 'join' two conditions together to create a dependency between them based on the type of 'join' being used. I currently have a simple object that contains the following methods:
public function addCondition ( Condition $conditi...
In the L2S designer I have dropped a table and a view. I tried adding an association between the 2 on their primary keys. This should be a one-to-one relationship, so I set the cardinality property of the association as such.
But, when coding I can't access the child property.
Any suggestions?
EditI just created a view in sql server ...
So I'm working on my own little MVC framework as a learning exercise. It's working great, but I want to be able to reference variables in my view files without $this.
So for example I have a controller object which instantiates a view object. From the controller I pass the variables to the view like this
$this->view->foo = "bar";
The...
When do you use each inheritance?
class Base{};
class Derived: protected Base{};
class Derived2: public Base{};
My case:
I have class called Snapshot which only contains GetXXX methods. It is a light-weight classed used to store current state of the Value class. I also use it for recovery, keeping instances of this class long after ...
Hi,
I have a base class that contains a fairly large number of parameters in it's New constructor. I have 7 subclasses that inherit the Super base class. My question/issue is, all of the subclasses use the same values for most of the parameters in the New constructor of the base class and these subclasses can be called one after the o...
During the process of designing new features in your software, which process is the best practice
Design the Interface that the Class will implement.
Writing the Class and extracting the Interface later.
If going the route of number 2, when do you decide that an Interface is needed?
...
How should I design a "Proper" OO Pong?
The idea of Proper being that any element can be changed: The shape of the ball, the court, and the paddles, adding obstacles, and even "powerups", like "can stick the ball to the paddle".
The two more pressing questions, right now, are:
Who checks for colissions? and
When a colission does happ...
I am writing a python platform for the simulation of distributed sensor swarms. The idea being that the end user can write a custom Node consisting of the SensorNode behaviour (communication, logging, etc) as well as implementing a number of different sensors.
The example below briefly demonstrates the concept.
#prewritten
class Sensor...
What's the point of both? When do you think it's appropriate to use either?
...
I've been reading Diaz's book Pro JavaScript Design Patterns. Great book. I myself am not a pro by any means. My question: can I have a static function that has access to private instance variables? My program has a bunch of devices, and an output of one can be connected to the input of another. This information is stored in the inputs a...
I have SalesMan class which is inherited from User class and also implements ISalesMan interface.
public class SalesMan : User, ISalesMan
{
...
}
I need to convert user objects into salesman objects. I understand that direct casting from User type of objects into SalesMan type is not possible. How should I do the converting? I'm thin...
I have class that I believe should not be a singleton or static class. It has state, albeit state that could be shared by consumers. I like to stay away from singletons when there is shared state, but the argument I'm hearing is that I will reap performance benefits from only ever having 1 instance of the object exist at any given time...
While filling in The Object Oriented Concepts Survey (To provide some academic researchers with real-life data on software design), I came upon this question:
What is the limit N of maximum methods you allow in your classes?
The survey then goes on asking if you refactor your classes once you reach this limit N.
I've honestly never th...
I have created an immediate object in OCaml.
let x =
object (self)
val dataMember = 3
method aMethod = print_endline "Called a method"
end;;
As the object doesn't have a name (is it considered anonymous?), how can it be correctly represented in UML?
Thanks.
...
Can a class extend both an interface and another class in PHP?
Basically I want to do this:
interface databaseInterface{
public function query($q);
public function escape($s);
//more methods
}
class database{ //extends both mysqli and implements databaseInterface
//etc.
}
How would one do this, simply doing:
class database impl...
What is the point of writing an interface without members ?
INamingContainer is one example in .NET Framework. And it's described in MSDN as :
Identifies a container control that
creates a new ID namespace within a
Page object's control hierarchy. This
is a marker interface only.
Is it used for just this kind of blocks :
...
This is probably very easy, but I'm stumped. I would like to create a general purpose class which will be used multiple times in my program. I want this to be very lightweight and super fast.
For a very simple example in C#:
public class SystemTest
{
public TestMethod(string testString)
{
if(testString == "blue")
...
why in C++, for objects A,B
//interface, case #1
class A {
B bb;
}
A::A()
{ //constructor
bb = B();
}
//interface, case #2
class A {
B *bb;
}
A::A()
{ //constructor
bb = new B();
}
Why case #2 work but not #1??
Edit: I got it now. But for case #1, if an instance of A is freed, will its bb also be automatically freed? Case #2 yo...
Hi all,
Here is the situation for which I am trying to find a suitable design.
I need to store profiles of numbers. A profile is just a series of numbers. They can be of either int, float or decimal type. Each profile has a ProfileDescription field based on an ennumeration.
Each Profile has a collection of ProfileVersion Object...