Is the Registry design pattern a good solution for this in PHP?
For a social network site (facebook, myspace).
let's say I have a Database class which creates a single DB connection and lets me do DB stuff and a Sessions class which lets me handle sessions as well as a Cache class which lets me cache items and retrieve them. SO that...
Is there a difference between defining member functions for a template class inside the class declaration versus outside?
Defined inside:
template <typename T>
class A
{
public:
void method()
{
//...
}
};
Defined outside:
template <typename T>
class B
{
public:
void method();
};
template <typename T>
void B<...
I'm trying to adhere to Single Responsibility Principle better, and I'm having issues grasping how to structure the general class design for communicating with a database. In a simplified version, I essentially have a database containing:
Manufacturer <== Probes <==> ProbeSettings
A probe has a manufacturer. A probe has 1 set of se...
Hi all,
I would like to use the tm struct as a static variable in a class. Spent a whole day reading and trying but it still can't work :( Would appreciate if someone could point out what I was doing wrong
In my class, under Public, i have declared it as:
static struct tm *dataTime;
In the main.cpp, I have tried to define and initia...
Hi everyone, once again I'm getting plagued by the dreaded Flash error: Cannot access a property or method.
I'm building a new video player and I need to send the total width of my progress bar(created in PlayerControls.as) to my VideoPlayer.as class. As well as control the width of the progress bar from an update function inside my Vid...
Below is a function I found about a year ago that is supposed to put a lock on a memcache key so you can update it's value without any trouble of 2 request trying to update the key at the same time.
It is pretty basic but I could use a little help in figuring out how to use it 100%. The part I am not sure about is where it passes in ...
Hi,
I have a class that needs to use a Class<T> parameter (see my previous semi-related question). It is:
public class BaseTable<T extends TableEntry>
{
protected Class<T> mClass;
...
public BaseTable(int rows, int cols, Class<T> clasz)
{
...
mClass = clasz;
}
public BaseTable(int rows, int col...
Consider a scenario that a java program imports the classes from jar files. If the same class resides in two or more jar files there could be a problem.
In such scenarios what is the class that imported by the program? Is it the class
with the older timestamp??
What are the practices we can follow to avoid such complications.
...
Hi,
Please could someone experienced in PHP help out with the following. Somewhere in my code, I have a call to a public static method inside a non-instantiated class:
$result = myClassName::myFunctionName();
However, I would like to have many such classes and determine the correct class name on the fly according to the user's langua...
Apologies in advance if this is a silly question but I'm wondering which might be faster/better in the following simplified scenario...
I've got registered users (in a users table) and I've got countries (in a countries table) roughly as follows:
USERS TABLE:
user_id (PK, INT) | country_id (FK, TINYINT) | other user-related fields...
...
I need to check if there exists an instance of class_A ,and if there does exist, get that instance.
How to do it in PHP?
As always,I think an simple example is best.
Now my problem has become:
$ins = new class_A();
How to storing the instance in a static member variable of class_A when instantiating?
It'll be better if the instanc...
I am trying to create a class called LinkButton, which is a simple class that loads a URL on a click (im doing this to simpify my designers' transition to AS3). Even though I am importing the button definition, the AS file gets a compile error: 1046: Type was not found or was not a compile-time constant: Button. and 1172: Definition fl....
Hi
Whats the best way to reset class attributes in Python.
I have a class whichs has about 20 class attributes, in my init I have
class MyClass:
def __init__(self)
self.time=0
self.pos=0
self.vel=0
self.acc=0
self.rot=0
self.dyn=0
.
These need to be reset on each iteration of my p...
Hi. Probably asking this shows that I don't have the convenient grasp on OOP, but...
How can I call a derived function from a base class? I mean, being able to replace one function from the base to the derived class.
Ex.
class a
{
public:
void f1();
void f2();
};
void a::f1()
{
this->f2();
}
/* here goes the a::f2() definit...
hey guys i know how to write a update script for my project , the easiest way is to write a file and give it to the user and ask him to go for it . but i want to update his website automatically .
exactly like wordpress as u can see user can click on a button and the script will do next steps.
problem is how to Downloading a zip file...
Hello!
I'm about to start translating my vb.net application, and I don't want to use the default methods provided by Visual Studio to do so. I need my application to be very light, and it nearly doubles it size to use the resources option.
Therefore, I'm planning to use some thing like a class, of which I would have one instance per la...
I was reading up some things about how to design a library or API well, and stumbled across Joshua Bloch's great talk at Google Tech Talks. Now although I am nowhere near a professional API developer, I think programming a bunch of classes/functions is a similar, although much scaled-down version of the same thing - clear-cut separation ...
I know that using the synchronize keyword before a method brings synchronization to that object.
That is, 2 threads running the same instance of the object will be synchronized.
However, since the synchronization is at the object level, 2 threads running different instances of the object will not be synchronized. So, if we have a static ...
I am trying to figure out how I want to handle settings in my PHP app. I have pretty much decide that I would like to use a Confg class file so it will be autoloaded and flexible in the future. Below is some stuff I was playing with.
I know you cannot set a variable to popluate a Constant so I then try to use a public static propert...
I can not figure out why I am getting this session error...
Warning: session_start()
[function.session-start]: Cannot send
session cache limiter - headers
already sent (output started at
C:\webserver\htdocs\project2\labs\form-submits\index.php:2)
in
C:\webserver\htdocs\project2\labs\form-submits\index.php
on line 2
...