oop

Designing a HTML tag class in PHP

I've recently learned OOP in PHP,.. and I though I'd try to write a class in PHP that generates tags for forms i.e. something that lets you generate forms. Its probably been done a billion times before/ or isn't a very good idea. I'm just doing it as an exercise. Anyway, how would I go about planning this? $form = new Form_Class($for...

c# permanent casting to a subclass

If: class Car : Automobile {} I can do: Car toyota = new Car(); Automobile tauto = (Automobile)toyota; but if I do tauto.GetType().Name it will still be Car. Is it possible to perform a cast, so that the type is permanently changed to Automobile (without having to clone the object) ? The problem i am trying to overcome is that...

What is meant by "getting the right level of abstraction"?

Hi, I've read about how a hard job in programming is writing code "at the right level of abstraction". Although abstraction is generally hiding details behind a layer, is writing something at the right level of abstraction basically getting the methodss to implement decision correct? For example, if I am going to write a class to repres...

Encapsulating Mutexes (or other synchronization primitives)

In all the code I've written, I have always made synchronization primitives wrapped in a single class. If my design ever produced an unencapsulated synch primitive, I redesigned until it was indeed encapsulated. But is there a well-known design force or development circumstance (besides legacy code) that would require unencapsulated sy...

Problems in Using Object Variable to Activate & Deactivate WordPress Hooks

First of all, I want to say sorry for this very big question, but all these questions were disturbing my little brain (or no brain!) for the past couple of days as I was not getting any suitable answer. I will request to first read this slowly, and whoever knows any part of it, please try to answer it for that part only. I will really be...

C++: Storing childs of a class in variables with it's type

I am currently working on a 2D game project and I want to switch from Delphi to C++. In Delphi, I could declare an array which had the type of a class Entity, and I could put Entitys as well as objects of classes which are derived from Entity into it. This would be very important for me, as it seems logical that all entities should be ...

How does the method syntax "public function direct(){}" work in PHP?

I'm learning Zend Framework at the moment and came across the following syntax. class Zend_Controller_Action_Helper_Redirector extends Zend_Controller_Action_Helper_Abstract { /** * Perform a redirect to an action/controller/module with params * * @param string $action * @param string $controller * @param...

OOP related question

Hi! I'm trying to improve my understanding on OOP^^ If I call this file... set_organization.php file: $organization = new Organization( ); $organization->name = 'Name here'; $organization->founder = 'Founder here'; then I access it again, are the name, and founder already set? Or should I put unset to ensure it's empty, like fresh s...

A way to avoid a virtual call in constructor

Consider the code in the following example: abstract class Car { public abstract Engine CarEngine { get; protected set; } public Car() { CarEngine.EngineOverheating += new EventHandler(CarEngine_EngineOverheating); } void CarEngine_EngineOverheating(object sender, EventArgs e) { // Subscribing t...

Books / tutorials on how to do object oriented analysis and design of algorithms?

There is readily available a lot on info on how to do analysis and design of standard CRUD applications, or at least, applications more geared to the traditional windows application - having a couple of windows, where you click on buttons and then things happen. In the backyard there is some sort of repository where you persist your info...

Multiple Calls To Function - Cannot redeclare class - php

I'm currently learning php, and I'm testing out oop and classes. My code is: <?php require('user.php'); $user = new User($username); $projects = $user->getProjects(); for ($n = 0; $n<count($projects); $n++) { echo "<li>"; echo "<a id=\"menu_pages\" href=\"\"><img src=\"../images/types/project.png\"/>" . $projects[$n]->name . ...

Calling method of another class in same file of class being used?

class.mysql.php has 2 classes: MySQL and MySQLResult class.mysql.php: <?php /** * MySQL Database Connection Class * @access public */ class MySQL { /** * MySQL server hostname * @access private * @var string */ var $host; /** * MySQL username * @access private * @var string */ ...

C++: "Class namespaces"?

If in C++ I have a class longUnderstandableName. For that class I have a header file containing its method declaration. In the source file for the class, I have to write longUnderstandableName::MethodA, longUnderstandableName::MethodB and so on, everywhere. Can I somehow make use of namespaces or something else so I can just write Metho...