I have the following code that creates two objects (ProfileManager and EmployerManager) where the object EmployerManager is supposed to inherit from the object ProfileManager.
However, when I do alert(pm instanceof ProfileManager); it returns false.
function ProfileFactory(profileType) {
switch(profileType)
{
case 'employe...
Hi,
I read about this ages ago but never tried it now I can't remember if this is possible or not. Is it possible to extend a class from two parents on php5 e.g.
class_d extends class_c and class_b
moreover can you do this if class_c and class_b are themselves extended from class_a ... so you get something like this
...
I want to design a class that will parse a string into tokens that are meaningful to my application.
How do I design it?
Provide a ctor that accepts a string, provide a Parse method and provide methods (let's call them "minor") that return individual tokens, count of tokens etc. OR
Provide a ctor that accepts nothing, provide a Parse ...
What is the lasting influence of C++ (not counting syntax) on the design of newer languages?
Edit: This question was originally titled "Is C++ dead? Has it stopped influencing the design of newer languages?" but got closed. However, some of the answers respond to the original title.
...
Ok,
So, I have a class library with all my database logic. My DAL/BLL.
I have a few web projects which will use the same database and classes, so I thought it was a good idea to abstract the Data Layer into its own project.
However, when it comes to adding functionality to classes for certain projects I want to to add method to cer...
I've been discussing a code style issue with a friend. We have a series of packages that implement an interface by returning a specific type of value via a named subroutine. For example:
package Foo::Type::Bar;
sub generate_foo {
# about 5-100 lines of code
return stuff here;
}
So you can go:
my $bar_foo = Foo::Type::Bar->gen...
In my application I have a Customer class and an Address class. The Customer class has three instances of the Address class: customerAddress, deliveryAddress, invoiceAddress.
Whats the best way to reflect this structure in a database?
The straightforward way would be a customer table and a separate address table.
A more denormalized ...
We recently had a code review . One of my classes was used so that I could return/pass more than one type of data from/to methods . The only methods that the class had were getters/setters . One of the team's members ( whose opinion I respect ) said that having a class like that is bad practice ( and not very OOP ) . Why is that ?
...
I want to implement a docking library in wpf with behavior similar to Adobe Photoshops CS3.
You can attach floating Panels to other Panels or Docks by mouse dragging. Docks have a fixed location.
Would you use a central Docking Manager class? How would the message flow look like? I was thinking of using 2 interfaces, called IDock and I...
When working in a big project that requires debugging (like every project) you realize how much people love "printf" before the IDE's built-in debugger. By this I mean
Sometimes you need to render variable values to screen (specially for interactive debugging).
Sometimes to log them in a file
Sometimes you have to change the visibility...
hi i forgot the code which in a sample class you have to add so that it runs automatically?
is it wakeup or something?
like so:
class something {
function automaticxxx_something_which_runs when class is created()
{
}
}
$s = new something();
-what do i create in the class file so that something runs already after the class is ini...
<?php
class Box
{
var $contents;
function Box($contents) {
$this->contents = $contents;
}
function get_whats_inside() {
return $this->contents;
}
}
?>
I am going through a OO tutorial. I am familiar with PHP and the concept of OO but it is still an uphill struggle most of the time! However, the code...
class Score
{
var $score;
var $name;
var $dept;
var $date;
function Score($score, $name, $dept, $date)
{
$this->scores = ($score);
$this->name = ($name);
$this->dept = ($dept);
$this->date = ($date);
}
function return_score(){
return $this->scores;
return $this->name;
return $this->dept;
return $this->date;
}
}...
This is a contrived example, but lets say I have declared objects:
CustomObj fooObj;
CustomObj barObj;
CustomObj bazObj;
And I have an string array:
string[] stringarray = new string[] {"foo","bar","baz"};
How can I programatically access and instantiate those objects using the string array, iterating using something like a foreach...
I tend to do a lot of projects on short deadlines and with lots of code that will never be used again, so there's always pressure/temptation to cut corners. One rule I always stick to is encapsulation/loose coupling, so I have lots of small classes rather than one giant God class. But what else should I never compromise on?
Update - t...
How to mark a class deprecated? I do not want to use a class anymore in my project, but do not want to delete it beforea period of 2 weeks.
...
So far i have got the code below which works lovely when trying an update, delete or select statement. However I run into problems when I try to use an insert. If someone could point me in the correct direction i would be grateful.
private function escape($value)
{
if(get_magic_quotes_gpc())
$value = stripslashes($value);
...
For our school project, we are tasked to define a design document describing the architecture of a PHP application.
We are free te decide what to include in the document.
Our professor suggested, lots of (UML) diagrams.
He also asked us to consider class diagrams, but with care, as PHP is not fully object oriented.
My question: Is a...
Is there some equivalent of "friend" or "internal" in php? If not, is there any pattern to follow to achieve this behavior?
Edit:
Sorry, but standard Php isn't what I'm looking for. I'm looking for something along the lines of what ringmaster did.
I have classes which are doing C-style system calls on the back end and the juggling has...
I'm refactoring a 500-lines of C++ code in main() for solving a differential equation. I'd like to encapsulate the big ideas of our solver into smaller functions (i.e. "SolvePotential(...)" instead of 50 lines of numerics code).
Should I code this sequentially with a bunch of functions taking very long parameters lists, such as:
int ...