So I have a class.. In its constructor I include the code which connects me to my database via the mysqli extension:
class MyClass
{
public function __construct()
{
include("dbconnect");
}
}
dbconnect looks like this:
$host = "localhost";
$user = "user";
$pass = "123";
$database = "myDatabase";
$mysqli = new mysq...
hey, hi i want put limit on object creation means a class can have at most suppose 4 objects not more than that how to achieve this?
...
Why do we need design patterns like Factory, Abstract Factory and Singleton?
...
I have a program (simple web server) which I try to understand. There is a class called MyHandler. In this class we define 2 methods do_GET and do_POST.
I do not understand several things:
Where do we use the two above defined methods? I would expect to see something like that objectname.do_GET() and objectname.do_POST() but I do not ...
I have an inheritance hierarchy similar to below and I want to write my DAL to persist these objects but am unsure as to the best way of structuring it?
Pet <- Dog <- Alsation and Labrador
Pet <- Cat <- Persian and Tabby
Although all classes inherit from Pet, each method will need to call a different stored procedure and add differe...
When you have a ignorant boss who doesn't know how to code or don't know anything about Object-Orientation then ditching out spaghetti is the best form of coding. Or is it? What to do?
...
I know about OOFNF (object oriented functional normal form) as an equivalence to normalization process in relational databases.
Does anybody knows about any other definitions??
Thank you
...
This has "always" bothered me...
Let's say I have an interface IFiddle and another interface that does nothing more than aggregate several distinct IFiddles:
public interface IFiddleFrobbler
{
IFiddle Superior { get; }
IFiddle Better { get; }
IFiddle Ordinary { get; }
IFiddle Worse { get; }
IFiddle Crackpot { get; }...
I've got a class A defined in a separate header file. I want class B to have a reference to a object of class A stored as a variable.
Like this:
File: A.h
class A {
//Header for class A...
};
File: B.h
#include "A.h"
class B {
private:
(24) A &variableName;
public:
(36) B(A &varName);
};
When i try to co...
Hi, I'm now starting out on DDD, I've already found a nice implementation for ValueObject but I cant seem to find any good implementation for Entities, i want a generic base entity type which will have an ID(needed by the specification) and implement currect equality operations.
Whats the most elegent solution?
...
Well it is more like a design question.
There are two ways I know to use joins in the Zend Framework
Deal with it using instance of Zend table( its Select obj)
Deal with it using the instance of Zend Db (its Select obj)
in the first approach it seems really strange to me - the some table have to be dealing with other tables too, whic...
I remarked the compiler generates a warning if I suppress the override/new (Overloads/Shadows) keyword. Normally, I set the necessary keyword.
But what if i forget it?
// >>>> Case A - not virtual property -
class MyPoint : Point
{
int X { get; set; } // vs new int X { get; set; }
}
// >>>> Case B - virtual property -
class Foo ...
I was wondering if the below code makes any sense, since the compiler warns that "the blank final field objects may not have been initialized". Is there a better way of doing this?
public abstract Test {
protected final ArrayList<Object> objects;
}
public TestSubA extends Test {
public TestSubA() {
objects = new ArrayList<Obje...
Assuming I have a system of three Classes.
The GameClass creates instances of both other classes upon initialization.
class FieldClass:
def __init__( self ):
return
def AnswerAQuestion( self ):
return 42
class PlayerClass:
def __init__( self ):
return
def DoMagicHere( self ):
# Access...
I would like to hear what do you think about the design of this issue. I have to write webservice to allow user to modify dictionaries in database.
I got xml schema which looks like this (it's simplified):
AdminService which is a root and has a choice with:
AddCode[@DictionaryName, @Code, @Description]
RemoveCode[@DictionaryName, @C...
Here is my situation. I am working with WMI in C#. Thankfully, I found MgmtClassGen.exe which generated all of the classes I need for now.
However, I have been going through the auto generated classes, and ripping out the common code to either a Utility class, or a base class. So far so good, got a lot of the code cleaned up. But I've h...
From perldoc -f bless:
bless REF,CLASSNAME
This function tells the thingy referenced by REF that it is now
an object in the CLASSNAME package.
Is there any way of obtaining an unblessed structure without unnecessary copying?
...
In the recent question "How to organize MATLAB code?" Andrew Janke mentioned in his answer using classes to organize MATLAB functions into packages:
... consider rewriting some of the code as objects, using stateless utility
classes with class methods and private functions as ways of packaging related
functions together and provi...
I want to improve my programming skills especially object programming. I want to write a simple game, but it shouldn't be too simple. I actually wrote classic Tetris and I want to try something more demanding. I need your help. Could you give me some idea or titles of games to look up to?
Thanks for all of the answers but I need a more ...
I am reading the book Applying-Domain-Driven-Design-Pattern.
In its model design, it has the Order hold reference to Customer, but if it was me doing the design, i will probably have the Customer hold reference to Order.
So, the question, when designing unidirectional relationship, how to decide the direction?
...