This pattern describes how we perform one task multiple times using a loop.
Joomla! uses numerous Design Patterns, many of which are far more complex than
the iterator pattern.
For a complete description of Design Patterns, you should consider reading the book
Design Patterns: Elements of Reusable Object-Oriented Software. This book, originally
published in 1994 and written by the Gang of Four, is considered the ultimate guide
and reference to software Design Patterns.
The factory pattern is a creational pattern used to build and return objects. The factory
pattern is used in cases where different classes, usually derived from an abstract
class, are instantiated dependent upon the parameters. Joomla! provides us with the
static class JFactory, which implements the factory pattern. This class is important
because it allows us to easily access and instantiate global objects.
Chapter 2
[ 31 ]
This example shows how we can access some of the global objects using JFactory.
$db =& JFactory::getDBO();
$user =& JFactory::getUser();
$document =& JFactory::getDocument();
More information about JFactory can be found in the Appendix.
Pages:
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53