oop

Standard OOP Techniques for listing style PHP projects

I'm building a freelancing site (think scriptlance) which has listings of projects both on the home page and the listings page. I thought it would be a good chance to implement OOP techniques. I was thinking I would create a project class which among other things would have a function to echo the relevant contents for the home and list...

Making Catalyst calls from the model?

I'm using Catalyst with Catalyst::Plugin::Authentication and Catalyst::Plugin::Authorization::Roles and am wondering if there is a better approach to adding an attribute to a model that I'm not seeing. Each user is permitted to access one or more companies, but there is always one primary (current) company at a time. The permitted list ...

Is this the equivalent function call to a Perl constructor call?

I can have a constructor like this : sub create { my $class = shift; my $self = {}; return bless $self,$class; } and when I create an object, I can write this: my $object = create Object; Is this: my $object = Object::create("Object"); the only equivalent to that constructor call? ...

Extended class not found when Base class is in a separate include file

This doesn't work: test.php: include_once('test-include.php'); $main = new mainClass(); //====================================================================== class mainClass { function __construct() { $test2 = new Test2(); echo $test2->var; } } //===============================================================...

Will PHP become a full fledged statically typed OOP language in the near future or ever?

I was wondering whether it is the intent of the development team of the PHP language to make it into a full fledged statically typed OOP language at some point. Any ideas about this? Edit: To add to that: Will this be a performance hit for a non-compiled language? Or are there similar purpose scripting languages that have these capabili...

How to view object's data in php

Hello when I want to test php array I use the following code print_r($myarray); but know I want to see the data of an object my object is $xpath = new DOMXPath($doc); $myobject = $xpath->query('//*[ancestor-or-self::a]'); when I use print_r($myobject); I get that output DOMNodeList Object ( ) I want to i...

Best way to implement customization hooks in my design

Hey SO, I am wondering what's the best way to insert customization hooks into my application. Basically, my application is split into two assemblies: A Core assembly containing all the business logic and a UserInterface assembly containing the GUI, controller classes (I am using a deviant MVC pattern callse "Passive View") and some help...

Instantiate a JavaScript Object Using a String to Define the Class Name

Here's what I'm trying to do -- this is pseudo code and doesn't work. Does anyone know how to accomplish this for reals: // Define the class MyClass = Class.extend({}); // Store the class name in a string var classNameString = 'MyClass'; // Instantiate the object using the class name string var myObject = new classNameString(); ...

Is there an OO Perl equivalent to an interface?

I know with OO Perl I can have objects and inheritance, but are interfaces implemented? If so, how are they enforced? ...

DDD: Should 'country' be a Value Object or an Entity?

Hi, 'country': Value Object or Entity in DDD? Opinions either way appreciated. And, where to store the table of country names/codes? DB? XML? In a class? Thanks! ...

PHP - How do I get the class name or filename of the object that instianiated the current object?

To clarify: I'm building a Logger class that allows me to easily log messages: lib.Logger.php: <?php class Logger { private $handle; public function __construct($log_name, $log_path) { if ( ! is_dir($log_path)) throw new Exception('Log path does not exist.'); if ( ! in_array(strtolower(substr($lo...

Strange problem with classes

I'm trying to make a simple game engine. I've never used OOP before, so this is probably a simple mistake, but I get this error when trying to create an instance of a class. invalid conversion from `World*' to `int' initializing argument 1 of `World::World(int)' This is the code to create the class. World w = new World(100); And ...

Pointers to classes

Looking at example under "Pointers to classes" (very bottom) How is it that we can use the dot operatior here: CRectangle * d = new CRectangle[2]; ... d[1].set_values (7,8); if d is a pointer? Same question for the lines: cout << "d[0] area: " << d[0].area() << endl; cout << "d[1] area: " << d[1].area() << endl; Also, For...

Access class static function via variable

So I have a PHP class called router that takes the URL and explodes it to find the requested component, action and any given values. It then loads the responsible class, runs the action, etc, etc. I am now integrationg user access into the class via an user class. For each component (which is a class), I have a static class array varia...

Java Program Structure Advice

Hi, I am building and sort of RSS reader in java as my first object-oriented program and would love some OO design tips. I have a Reader class with a list of Feed objects for RSS feeds, and each Feed downloads news items into Article objects in an Articles list. What I want to do is find a way to relate articles from multiple sources....

Object design with lately added attribute

Hi, In my E-commerce application, I want to add a attribute to a Product, only after it was added to a Category.(Not all Products are in a Category here). How can I design the Product class? Thanks in advance! ...

Would you implement a strategy pattern here and if yes, how?

Consider an application that generates production plans (simplified code sample below) . There's a big list of products and we call product.GetProductionTime() many times while doing complex calculations in the production plan. We need product.GetProductionTime() to behave differently based on the planning algorithm we are using or the s...

PHP object class variable

I have built a class in PHP and I must declare a class variable as an object. Everytime I want to declare an empty object I use: $var=new stdClass; But if I use it to declare a class variable as class foo { var $bar=new stdClass; } a parse error occurs. Is there a way to do this or must I declare the class variable as an object...

Is there any UML reference card available?

Are any reference card or cheat sheet available for UML? ...

Preventing class data inheritance (PHP)

Hello, I have a database abstraction layer that starts with a base class like so: class DB { function DB() { $this->host = "xxx"; $this->db = "xxx"; $this->user = "xx"; $this->pass = "xx"; $this->dbh = mysql_connect($this->host, $this->user, $this->pass); mysql_select_db($this->db); // etc } } class DB...