Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objects having knowledge of each other

In Zend Framework ,Zend_Application object has a bootstrap object to bootstrap or configure the components.Bootstrap class in turn have access to zend_application object to access configuration parameters.
My Question is that what kind of pattern is this or is it a code smell because of circular dependency.

like image 270
Tarun Avatar asked Aug 31 '12 13:08

Tarun


People also ask

What are the objects of knowledge?

The object of knowledge is the external world as it is independently of what we say or think about it and independently of our epistemic access to (perceptions of) the world. Sense perceptions are internally conditioned which is why they do not directly inform us about the real character of the world.

What are Plato's objects of knowledge?

Thus Forms are the objects of knowledge while physical objects are objects of opinions. The former are "seen" with the mind, the latter with the senses. But it is essential to Plato's view that Forms are not themselves "in the mind".

What are the objects of philosophy?

Objects of knowledge of philosophy are "three whales": first, a person, and more broadly any reasonable being and its structure, and secondly, the surrounding world, including the world of ideas and other worlds - explicit, hypothetically possible and probable, in third, the relationship of the rational being to ...

Do objects exist independently of our minds?

Idealism. The idealist philosopher George Berkeley argued that physical objects do not exist independently of the mind that perceives them. An item truly exists only as long as it is observed; otherwise, it is not only meaningless but simply nonexistent.


1 Answers

Zend Framework 1 is bloated, that's for sure.

The reason for that $_application property representing a bi-directional relation is due to the module's independent bootstrap files.

It's strange, I think, because when dealing with modules, instead of having the Zend_Aplication set you'll have the main bootstrap instead:

/**
 * Set application/parent bootstrap
 *
 * @param  Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
 * @return Zend_Application_Bootstrap_BootstrapAbstract
 */
public function setApplication($application)
{
    if (($application instanceof Zend_Application)
        || ($application instanceof Zend_Application_Bootstrap_Bootstrapper)
    ) {
        if ($application === $this) {
            throw new Zend_Application_Bootstrap_Exception('Cannot set application to same object; creates recursion');
        }
        $this->_application = $application;
    } else {
        throw new Zend_Application_Bootstrap_Exception('Invalid application provided to bootstrap constructor (received "' . get_class($application) . '" instance)');
    }
    return $this;
}

There's a lot of code smell too:

/**
 * Constructor
 *
 * Sets application object, initializes options, and prepares list of
 * initializer methods.
 *
 * @param  Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
 * @return void
 * @throws Zend_Application_Bootstrap_Exception When invalid application is provided
 */
public function __construct($application)
{
    $this->setApplication($application);
    $options = $application->getOptions();
    $this->setOptions($options);
}

The boostrap file need the options, so instead of asking for the options, it expects the Zend_Application to then get the options:

$options = $application->getOptions();
$this->setOptions($options);

It seems like they simply ignore the type of interface expected by the setApplication() method and it can be one of the followings:

  • Zend_Application
  • Zend_Application_Bootstrap_Bootstrapper
  • Zend_Application_Bootstrap_ResourceBootstrapper

I would give up trying to understand this mess and switch to ZF 2, though ;)

like image 179
Keyne Viana Avatar answered Oct 02 '22 22:10

Keyne Viana