I am trying to make a script in which different classes (e.g. Database, Utilities, Config) are all used to form one central Main class. I have tried extending a chain of them:
Main -> Utilities -> Database -> Configuration
But how can I set the different parts so that they can be called like this:
<?php
$this->db->select("WAFFLE...
I have extended PDOStatement and modified the fetch() method to typecast values of the types timestamp and arrays, in PostgreSQL, to DateTime and native array. This works as intended but I can't override the behaviour when using the statement in a foreach.
I have solved this by returning rows into an object implementing ArrayAccess, Ite...
Hi,
I am about to add a class X that will be used by my three previously designed classes (A, B and C).
The new class X will contain data and functions for new features as well as provide services to the classes that use it to hide lower layers. The problem is that A, B and C will use class X quite differently, that is, use different ...
I am trying to achieve something like the following:
class Foo
{
public virtual int Number { get; set; }
public Foo(int n)
{
Number = n; //Virtual member call in constructor
}
public void Do() {
Console.WriteLine(Number);
}
}
class Bar : Foo
{
public override int Number
{
get
...
I am implementing a few strategies (Strategy Pattern) which have some common behavior and am undecided where the common operations should live.
Assuming I 1 context and 3 strategies, some of the operations used in the strategies are shared, some are needed only by 2 others just be 1 of the strategies.
There is no member level state s...
I understand that it's better if objects are not responsible for their own persistence (makes testing the objects easier, plus separation of responsibilities), but then what object should handle persistence of domain objects, and what should the persistence API look like at a high-level?
...
I realize that it's possible to define a static class method as private and protected in PHP. This allows for an instantiated class, or public static method to access it's own private/protected static methods.
protected static function jumpOver ()
However I'm not sure if this is legal in the sense of OOP design. I can't find any real...
I need to define an element from linkedList in a object:
A
/ \
X Y
How could I name the entire object and its components in English?
à la: Hand-Body-Leg object named Body. or maybe somthing like queue kernel hand treeObject?
Ok, let's show you the example of a railway:
NodeStation => Station => Station =>
...
Possible Duplicate:
Why pure virtual function is initialized by 0?
In C++, what does it mean to set a function declaration to zero? I'm guessing it has to do with the function being virtual, and not actually defined in this class. Found in a header file of code that I'm reading:
virtual void SetValue(double val)=0;
What's...
I'm working in a C# codebase that has a class hierarchy:
class Animal { Animal prey; }
class Mammal : Animal { Mammal[] livesAmicablyWith; }
class Lion : Mammal { }
Forgive the stupid example.
I would like to repurpose this class hierarchy for something representable in the same exact object format, but which requires more data. In ...
I generally live by the rule that Global variables / functions are evil and that every piece of code should live in the class to which it pertains.
This is a very easy rule to follow, and I believe that I haven't ever run into an issue with this rule until now.
Today, however, I need to add a function to my assembly rather than to a sp...
Hi, I am trying to write Classes to show some people in my skill test. One of the questions is as follow:
Show how a child would call a parent's method. Show how overloading works. Indicate the syntax for class variables.
I think I got most of the question done but not sure what Indicate the syntax for class variables mean...Could som...
Hi Experts,
I know that my this question may sound pathetic to you but as a beginner in .NET, it means a lot to me.
I just want to know that how can I utilize the concept of Abstract class, virtual class etc. in my shopping cart website. I have read the tutorial out there on internet and I saw some examples too, but those examples are ...
What are other purposes of private method/variable other than for protection.
...
In my framewrok I have an ITransaction interface.
It implements some basic operations like Commit() and Rollback(), it is being used for flat files and other data sources.
However NHibernate has an ITransaction interface as well.
It is not the same as my interface since there are some database specific methods but there are similarities....
I want to implement the observer pattern and I want class X to observe updates in classes A and B.
X is derived from the abstract base class XObs which has the update() function taking an enum as parameter of what has happened.
The logical problem here is that X needs to know which of A and B sent the update and X cannot determine th...
I have looked around and could not find any similar question.
Here is the paragraph I got from Wikipedia:
Polymorphism is not the same as method overloading or method overriding. Polymorphism is only concerned with the application of specific implementations to an interface or a more generic base class. Method overloading refers to me...
As the title (sort of) explains, when I'm prototyping in JS, and I need to reference another function of the object, should I access the protoypal version of it, or the local variables version? Is there any (major) overhead issues involved with either one?
//starting off
Foo = function(){ }
Foo.prototype.ShowMessage = function(msg){
...
What is the use/advantage of function overloading?
...
Hi,
I'm working on a c++ app and I'm facing a problem:
I have a class B derived from the abstract class A that has some event handling methods. A third class C is derived from B and must reimplement some of B methods. Is there a way to implicitly call B's method before calling C's one?
Class diagram:
class A
{
virtual void OnKeyPr...