Tough questions



Studying away for the Zend exam (www.phparchitect.com) and 2 questions
have come up in the mocks which are confusing:

1) The __________ interface implements a useful design pattern which
allows you to overload an instance of an object so it can be accessed
like an array
[Confusion here - because of the overloading - is the answer simply
ArrayAccess?]

2) The following PHP script is an example of which design pattern?

<?php

interface HashAlgorithm {
public function hash($value);
}

class MyClass {

private $value;

public function __construct($value) {
$this->value = $value;
}

public function hash(HashAlgorithm $a) {
return $a->hash($this->value);
}
}

class MD5Hash implements HashAlgorithm {
public function hash($value) {
return md5($hash);
}
}


$obj = new MyClass("John");
$obj->hash(new MD5Hash());

?>
What pattern is this? I've looked through the regulars and not using
patterns regularly - can't see which it is.

A general Q - why is MVC so good? I understand it to be index.php?
page_to_redirect - with just it routing people to various pages. Why
is this such a good idea? I don't see a) how this separates business
logic and b) where the advantages come for say a single designer/
administrated site? To separate business logic - why couldn't I just
use a simple templating system? Maybe its a dumb question.

Thanks in advance.

A
.



Relevant Pages

  • Learning patterns... Decorator
    ... I'm trying to learn patterns, which I hope to use in my PHP code, although I'm finding it hard to get any real impression of how patterns fit in properly, I've done the following test code for Decorator pattern and want to know: ... public function getName; ... class CProduct implements IProduct { ...
    (comp.lang.php)
  • Re: Function shortcut help
    ... Helmut, and Tony: ... Sorry for the confusing post, ... Public Function MyResult(x As String, ...
    (microsoft.public.word.vba.general)
  • How do you look for two distinct patterns (RegExp)
    ... I have a regular expression with defined pattern. ... I want to evalute both the pattern in the code ... What is the proper syntax for passing more than one string to the pattern ... Public Function CellHasWhatIAmLookingForAs Variant ...
    (microsoft.public.excel.programming)