[Typo3-dev] singletons instead of pre-loaded objects

Leendert Brouwer usenet at daholygoat.com
Thu Aug 12 21:18:10 CEST 2004


"Wolfgang Klinger" <wolfgang at stufenlos.net> wrote in message
news:mailman.73.1092323218.12086.typo3-dev at lists.netfielders.de...
>
>  *hiya!*
>
>  On Thu, 12 Aug 2004, Karsten Dambekalns wrote the following:
> > Anyway, end of thread!?
> >
>
>  One last thing...
>  I would like to see an extension from Leendert
>  (haven't found anything in the ext rep), just as an example...
>

That's because none of it is public :) (I was making a link checker but ran
into the problem that I couldn't run it from a cron, searched for
alternatives, ran out of time, left it at that). If you look at the small
addition I made to tt_guest (in cvs) you'll see that the prev/next logic is
abstracted away in its own class. My extensions are not more exciting than
any other OO application. Here's a basic UML schema of what I'm implementing
currently. It's a little application that emulates a "study guide". Based on
previous education, the study guide determines what studies you can do after
that previous education. There are several trails you can walk through, and
trails can be archived. In each trail, there are a number of educations you
can choose from (links), and each education contains a number of follow-up
educations (results), which have links to external url's designated sites
for these educations. Right before the application redirects to the
designated site, data of the whole user session for the trail is logged, so
that trend statistics can be seen. The main() plugin function does nothing
but instantiating the TrailController. The TrailController acts as a Front
Controller (PEAA pattern, it's in the catalog) for the application. All the
classes you see are used both on the front end (plugin side) and backend (it
has a backend module as well, where maintainers of the site can maintain the
trails, educations and so on). Oh yeah, in case you don't understand the
uml: on top is the class name, then a line of dashes, then the variables,
then another dashed line, then the functions. Variables or functions prefixe
d with a minus (-) are private, with a plus (+) are public. I'm using the
Lazy Load pattern (another PEAA pattern) to take care of efficient loading
in each object (that's what the loaded variable (boolean), and the private
_load() function is for).

tx_studiewijzer_pi
------------------
+main(content, conf[])

tx_studiewijzer_TrailController
-------------------------------
-loaded
-trails[]
-------------------------------
+tx_studiewijzer_TrailController()
+get_active_trails()
+get_archived_trails()
+get_all_trails()
+get_view()
-_log()

tx_studiewijzer_Trail
---------------------
-loaded
-id
-attributes[]
-links[]
---------------------
+Trail(id)
+get_attrib(attrib)
+set_attrib(key,attrib)
+save()
-_load()

tx_studiewijzer_Link
---------------------
-loaded
-id
-attributes[]
-results[]
----------------------
+Link(id)
+get_attrib(attrib)
+set_attrib(key,attrib)
+save()
-_load()

tx_studiewijzer_Result
-----------------------
-loaded
-id
-attributes[]
-----------------------
+Result
+get_attrib(attrib)
+set_attrib(key,attrib)
+save()
-_load()

Pretty simple isn't it? Anyway, I have something a bit more exciting in
store soon maybe. I'm working on getting my toolkit right, which contains
classes for applying the Command pattern (GoF), Front Controller (as you've
seen, PEAA, the toolkit will hold 2 variants of it) and a set of
Intercepting Filters (mentioned in PEAA too but I can't remember which book
I first read about them). It also holds a unit testing framework which is
already available (phpunit). I definitely plan on making this extension
public, and maybe I should write a tutorial around it, so that people know
what I mean with all the fancy terms ;)
Oh yeah btw, I checked and my article about Refactoring is actually online,
if you get the free pdf copy here: https://www.entwickler.com/ssl/phppdf/ ,
the article is in the PDF. It's called "Refactoring techniques - Cleaning up
your code" or something.






More information about the TYPO3-dev mailing list